This commit is contained in:
Lunny Xiao 2014-04-11 15:38:09 +08:00
parent a18c751d44
commit 22c515f1e0
3 changed files with 14 additions and 1 deletions

View File

@ -30,11 +30,12 @@ type Column struct {
IsCascade bool IsCascade bool
IsVersion bool IsVersion bool
fieldPath []string fieldPath []string
DefaultIsEmpty bool
} }
func NewColumn(name, fieldName string, sqlType SQLType, len1, len2 int, nullable bool) *Column { func NewColumn(name, fieldName string, sqlType SQLType, len1, len2 int, nullable bool) *Column {
return &Column{name, fieldName, sqlType, len1, len2, nullable, "", make(map[string]bool), false, false, return &Column{name, fieldName, sqlType, len1, len2, nullable, "", make(map[string]bool), false, false,
TWOSIDES, false, false, false, false, nil} TWOSIDES, false, false, false, false, nil, false}
} }
// generate column description string according dialect // generate column description string according dialect

View File

@ -1,6 +1,7 @@
package core package core
import ( import (
"fmt"
"strings" "strings"
"time" "time"
) )
@ -29,6 +30,8 @@ type Dialect interface {
SqlType(t *Column) string SqlType(t *Column) string
SupportInsertMany() bool SupportInsertMany() bool
QuoteStr() string QuoteStr() string
RollBackStr() string
DropTableSql(tableName string) string
AutoIncrStr() string AutoIncrStr() string
SupportEngine() bool SupportEngine() bool
SupportCharset() bool SupportCharset() bool
@ -83,6 +86,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 (db *Base) RollBackStr() string {
return "ROLL BACK"
}
func (db *Base) DropTableSql(tableName string) string {
return fmt.Sprintf("DROP TABLE IF EXISTS `%s`", tableName)
}
func (b *Base) CreateTableSql(table *Table, tableName, storeEngine, charset string) string { func (b *Base) CreateTableSql(table *Table, tableName, storeEngine, charset string) string {
var sql string var sql string
sql = "CREATE TABLE IF NOT EXISTS " sql = "CREATE TABLE IF NOT EXISTS "

View File

@ -17,6 +17,7 @@ type Table struct {
Created map[string]bool Created map[string]bool
Updated string Updated string
Version string Version string
Cacher Cacher
} }
func (table *Table) Columns() map[string]*Column { func (table *Table) Columns() map[string]*Column {