protected override string WriteDataType(DatabaseColumn column) { var type = new DataTypeWriter().WriteDataType(column); type += (!column.Nullable ? " NOT NULL" : string.Empty); var defaultValue = column.DefaultValue; if (!string.IsNullOrEmpty(defaultValue)) { defaultValue = FixDefaultValue(defaultValue); const string defaultConstraint = " DEFAULT "; var dbDataType = column.DbDataType.ToUpperInvariant(); if (DataTypeConverter.IsVariableString(dbDataType)) { type += defaultConstraint + "'" + defaultValue + "'"; } else //numeric default { type += defaultConstraint + defaultValue; } } //cannot detect the "GENERATED BY DEFAULT" vs "GENERATED ALWAYS" version? if (column.IsAutoNumber) type += " GENERATED BY DEFAULT AS IDENTITY"; if (column.IsPrimaryKey && Table.PrimaryKey.Columns.Count == 1) type += " PRIMARY KEY"; return type; }
protected override string WriteDataType(DatabaseColumn column) { var type = new DataTypeWriter().WriteDataType(column); type += (!column.Nullable ? " NOT NULL" : string.Empty); var defaultValue = column.DefaultValue; if (!string.IsNullOrEmpty(defaultValue)) { defaultValue = FixDefaultValue(defaultValue); const string defaultConstraint = " DEFAULT "; var dbDataType = column.DbDataType.ToUpperInvariant(); if (DataTypeConverter.IsVariableString(dbDataType)) { type += defaultConstraint + "'" + defaultValue + "'"; } else //numeric default { type += defaultConstraint + defaultValue; } } //cannot detect the "GENERATED BY DEFAULT" vs "GENERATED ALWAYS" version? if (column.IsAutoNumber) { type += " GENERATED BY DEFAULT AS IDENTITY"; } if (column.IsPrimaryKey && Table.PrimaryKey.Columns.Count == 1) { type += " PRIMARY KEY"; } return(type); }