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
IsVersion bool
fieldPath []string
DefaultIsEmpty bool
}
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,
TWOSIDES, false, false, false, false, nil}
TWOSIDES, false, false, false, false, nil, false}
}
// generate column description string according dialect

View File

@ -1,6 +1,7 @@
package core
import (
"fmt"
"strings"
"time"
)
@ -29,6 +30,8 @@ type Dialect interface {
SqlType(t *Column) string
SupportInsertMany() bool
QuoteStr() string
RollBackStr() string
DropTableSql(tableName string) string
AutoIncrStr() string
SupportEngine() bool
SupportCharset() bool
@ -83,6 +86,14 @@ func (b *Base) Quote(c string) string {
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 {
var sql string
sql = "CREATE TABLE IF NOT EXISTS "

View File

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