move database-specific code into dialects (#11884)

This commit is contained in:
Dan Cech
2018-05-10 16:54:21 +02:00
committed by Torkel Ödegaard
parent 27e1c67453
commit 1dfff74da9
32 changed files with 334 additions and 244 deletions
+2 -41
View File
@@ -15,48 +15,9 @@ type Column struct {
}
func (col *Column) String(d Dialect) string {
sql := d.QuoteStr() + col.Name + d.QuoteStr() + " "
sql += d.SqlType(col) + " "
if col.IsPrimaryKey {
sql += "PRIMARY KEY "
if col.IsAutoIncrement {
sql += d.AutoIncrStr() + " "
}
}
if d.ShowCreateNull() {
if col.Nullable {
sql += "NULL "
} else {
sql += "NOT NULL "
}
}
if col.Default != "" {
sql += "DEFAULT " + col.Default + " "
}
return sql
return d.ColString(col)
}
func (col *Column) StringNoPk(d Dialect) string {
sql := d.QuoteStr() + col.Name + d.QuoteStr() + " "
sql += d.SqlType(col) + " "
if d.ShowCreateNull() {
if col.Nullable {
sql += "NULL "
} else {
sql += "NOT NULL "
}
}
if col.Default != "" {
sql += "DEFAULT " + d.Default(col) + " "
}
return sql
return d.ColStringNoPk(col)
}