Merge branch 'master' of github.com:go-xorm/core

This commit is contained in:
Nash Tsai 2014-04-14 15:30:55 +08:00
commit 720f2e2f6d
2 changed files with 27 additions and 8 deletions

View File

@ -51,11 +51,13 @@ func (col *Column) String(d Dialect) string {
} }
} }
if d.ShowCreateNull() {
if col.Nullable { if col.Nullable {
sql += "NULL " sql += "NULL "
} else { } else {
sql += "NOT NULL " sql += "NOT NULL "
} }
}
if col.Default != "" { if col.Default != "" {
sql += "DEFAULT " + col.Default + " " sql += "DEFAULT " + col.Default + " "
@ -69,11 +71,13 @@ func (col *Column) StringNoPk(d Dialect) string {
sql += d.SqlType(col) + " " sql += d.SqlType(col) + " "
if d.ShowCreateNull() {
if col.Nullable { if col.Nullable {
sql += "NULL " sql += "NULL "
} else { } else {
sql += "NOT NULL " sql += "NOT NULL "
} }
}
if col.Default != "" { if col.Default != "" {
sql += "DEFAULT " + col.Default + " " sql += "DEFAULT " + col.Default + " "

View File

@ -30,12 +30,15 @@ type Dialect interface {
SqlType(t *Column) string SqlType(t *Column) string
SupportInsertMany() bool SupportInsertMany() bool
QuoteStr() string QuoteStr() string
AndStr() string
EqStr() string
RollBackStr() string RollBackStr() string
DropTableSql(tableName string) string DropTableSql(tableName string) string
AutoIncrStr() string AutoIncrStr() string
SupportEngine() bool SupportEngine() bool
SupportCharset() bool SupportCharset() bool
IndexOnTable() bool IndexOnTable() bool
ShowCreateNull() bool
IndexCheckSql(tableName, idxName string) (string, []interface{}) IndexCheckSql(tableName, idxName string) (string, []interface{})
TableCheckSql(tableName string) (string, []interface{}) TableCheckSql(tableName string) (string, []interface{})
@ -78,6 +81,10 @@ func (b *Base) DriverName() string {
return b.driverName return b.driverName
} }
func (b *Base) ShowCreateNull() bool {
return true
}
func (b *Base) DataSourceName() string { func (b *Base) DataSourceName() string {
return b.dataSourceName return b.dataSourceName
} }
@ -86,6 +93,14 @@ func (b *Base) Quote(c string) string {
return b.dialect.QuoteStr() + c + b.dialect.QuoteStr() 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 { func (db *Base) RollBackStr() string {
return "ROLL BACK" return "ROLL BACK"
} }