Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public Column(string name, Table table)
 {
     Name        = name;
     Table       = table;
     Annotations = new HashSet <Annotation>();
     Length      = new ColumnLength();
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public void SqlTypeMaxSizeIsParsed(string type, int maxSize)
        {
            ColumnLength expected = new ColumnLength()
            {
                MaxSize = maxSize
            };

            ColumnLength actual = SqliteLengthParser.GetSqlLengthFromString(type);

            Assert.Equal(expected, actual);
        }