diff --git a/column.go b/column.go index 4e179a14..20b3ad01 100644 --- a/column.go +++ b/column.go @@ -51,10 +51,12 @@ func (col *Column) String(d Dialect) string { } } - if col.Nullable { - sql += "NULL " - } else { - sql += "NOT NULL " + if d.ShowCreateNull() { + if col.Nullable { + sql += "NULL " + } else { + sql += "NOT NULL " + } } if col.Default != "" { @@ -69,10 +71,12 @@ func (col *Column) StringNoPk(d Dialect) string { sql += d.SqlType(col) + " " - if col.Nullable { - sql += "NULL " - } else { - sql += "NOT NULL " + if d.ShowCreateNull() { + if col.Nullable { + sql += "NULL " + } else { + sql += "NOT NULL " + } } if col.Default != "" { diff --git a/dialect.go b/dialect.go index 2837d23e..8fcf78ff 100644 --- a/dialect.go +++ b/dialect.go @@ -30,12 +30,15 @@ type Dialect interface { SqlType(t *Column) string SupportInsertMany() bool QuoteStr() string + AndStr() string + EqStr() string RollBackStr() string DropTableSql(tableName string) string AutoIncrStr() string SupportEngine() bool SupportCharset() bool IndexOnTable() bool + ShowCreateNull() bool IndexCheckSql(tableName, idxName string) (string, []interface{}) TableCheckSql(tableName string) (string, []interface{}) @@ -78,6 +81,10 @@ func (b *Base) DriverName() string { return b.driverName } +func (b *Base) ShowCreateNull() bool { + return true +} + func (b *Base) DataSourceName() string { return b.dataSourceName } @@ -86,6 +93,14 @@ func (b *Base) Quote(c string) string { return b.dialect.QuoteStr() + c + b.dialect.QuoteStr() } +func (b *Base) AndStr() string { + return "AND" +} + +func (b *Base) EqStr() string { + return "=" +} + func (db *Base) RollBackStr() string { return "ROLL BACK" }