public static ColumnLength GetSqlLengthFromString(string type) { var columnLength = new ColumnLength(); if (string.IsNullOrWhiteSpace(type)) { return(columnLength); } string processed = PreProcessType(type); var matches = digitsRegex.Match(processed); if (matches.Length > 0 && matches.Groups.Count >= 3) { _ = int.TryParse(matches.Groups[1].Value, out int d1); _ = int.TryParse(matches.Groups[2].Value, out int d2); if (d1 > 0 && d2 > 0) { return(columnLength with { Precision = d1, Digits = d2 }); } else { return(columnLength with { MaxSize = d1 }); } } return(columnLength); }
public Column(string name, Table table) { Name = name; Table = table; Annotations = new HashSet <Annotation>(); Length = new ColumnLength(); }
public void SqlTypeMaxSizePrecisionAndDigitsAreParsed(string type, int maxSize, int precision, int digits) { ColumnLength expected = new ColumnLength() { MaxSize = maxSize, Digits = digits, Precision = precision }; ColumnLength actual = SqliteLengthParser.GetSqlLengthFromString(type); Assert.Equal(expected, actual); }
public void SqlTypeMaxSizeIsParsed(string type, int maxSize) { ColumnLength expected = new ColumnLength() { MaxSize = maxSize }; ColumnLength actual = SqliteLengthParser.GetSqlLengthFromString(type); Assert.Equal(expected, actual); }