protected DataTypeInfo(SqlDataTypeSpecification sqlDataType, Dictionary <string, SqlCreateUserDefinedDataTypeStatement> userDataTypes) { var userType = Helper.GetQualifiedName(sqlDataType.DataType.ObjectIdentifier); if (userDataTypes.ContainsKey(userType)) { sqlDataType = userDataTypes[userType].DataType; } var type = sqlDataType.DataType.ObjectIdentifier.ObjectName.Value.ToUpper( ); if (_DataTypes.ContainsKey(type)) { _DataTypes[type].Invoke(this, ""); if (sqlDataType.Argument1.HasValue) { Size = sqlDataType.Argument1.Value; } if (sqlDataType.Argument2.HasValue) { Precision = sqlDataType.Argument2.Value; } } else { throw new NotImplementedException($"DataType [{type}] is not implemented"); } }
public Column(Table table, string name, SqlDataTypeSpecification sqlDataType, Dictionary <string, SqlCreateUserDefinedDataTypeStatement> userDataTypes, int order) : base(sqlDataType, userDataTypes) { ParentTable = table; Name = name; Order = order; IsNullable = true; IsRowVersion = sqlDataType.DataType.ObjectIdentifier.ObjectName.Value.ToLower() == "rowversion"; }
public SqlTableDefinitionFormatter(FormatterVisitor visitor, SqlTableDefinition codeObject) : base(visitor, codeObject) { CommaSeparatedListFormatter = new CommaSeparatedListFormatter(visitor, codeObject, true); // figure out the size of paddings required to align column definitions in a "columnar" form if (FormatOptions.AlignColumnDefinitionsInColumns) { int range1MaxLength = 0; int range2MaxLength = 0; foreach (SqlCodeObject child in CodeObject.Children) { if (child is SqlColumnDefinition && !(child is SqlComputedColumnDefinition)) { SqlIdentifier identifierChild = child.Children.ElementAtOrDefault(0) as SqlIdentifier; if (identifierChild == null) { throw new FormatFailedException("unexpected token at index start Token Index"); } string s1 = child.TokenManager.GetText(identifierChild.Position.startTokenNumber, identifierChild.Position.endTokenNumber); range1MaxLength = Math.Max(range1MaxLength, s1.Length); SqlDataTypeSpecification dataTypeChildchild = child.Children.ElementAtOrDefault(1) as SqlDataTypeSpecification; // token "timestamp" should be ignorred if (dataTypeChildchild != null) { string s2 = child.TokenManager.GetText(dataTypeChildchild.Position.startTokenNumber, dataTypeChildchild.Position.endTokenNumber); range2MaxLength = Math.Max(range2MaxLength, s2.Length); } } } PaddedSpaceSeparatedListFormatter.ColumnSpacingFormatDefinition d1 = new PaddedSpaceSeparatedListFormatter.ColumnSpacingFormatDefinition(typeof(SqlIdentifier), typeof(SqlDataTypeSpecification), range1MaxLength + 1); PaddedSpaceSeparatedListFormatter.ColumnSpacingFormatDefinition d2 = new PaddedSpaceSeparatedListFormatter.ColumnSpacingFormatDefinition(typeof(SqlDataTypeSpecification), null, range2MaxLength + 1); List <PaddedSpaceSeparatedListFormatter.ColumnSpacingFormatDefinition> columnSpacingFormatDefinitions = new List <PaddedSpaceSeparatedListFormatter.ColumnSpacingFormatDefinition>(2); columnSpacingFormatDefinitions.Add(d1); columnSpacingFormatDefinitions.Add(d2); Visitor.Context.CurrentColumnSpacingFormatDefinitions = columnSpacingFormatDefinitions; } }
public override void Visit(SqlDataTypeSpecification codeObject) { _stringBuilder.Append(codeObject.Sql.ToUpper()); }
public override void Visit(SqlDataTypeSpecification codeObject) { Format(codeObject); }