add some interface for dialect

This commit is contained in:
Lunny Xiao 2014-04-13 15:37:25 +08:00
parent 3dd33af2d6
commit 46546777ae
2 changed files with 27 additions and 8 deletions

View File

@ -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 != "" {

View File

@ -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"
}