orm support auto create db

This commit is contained in:
slene
2013-08-19 22:37:39 +08:00
parent 1fedaf21ec
commit c38abf35da
16 changed files with 470 additions and 397 deletions

View File

@@ -20,6 +20,26 @@ var postgresOperators = map[string]string{
"iendswith": "LIKE UPPER(?)",
}
var postgresTypes = map[string]string{
"auto": "serial NOT NULL PRIMARY KEY",
"pk": "NOT NULL PRIMARY KEY",
"bool": "bool",
"string": "varchar(%d)",
"string-text": "text",
"time.Time-date": "date",
"time.Time": "timestamp with time zone",
"int8": `smallint CHECK("%COL%" >= -127 AND "%COL%" <= 128)`,
"int16": "smallint",
"int32": "integer",
"int64": "bigint",
"uint8": `smallint CHECK("%COL%" >= 0 AND "%COL%" <= 255)`,
"uint16": `integer CHECK("%COL%" >= 0)`,
"uint32": `bigint CHECK("%COL%" >= 0)`,
"uint64": `bigint CHECK("%COL%" >= 0)`,
"float64": "double precision",
"float64-decimal": "numeric(%d, %d)",
}
type dbBasePostgres struct {
dbBase
}
@@ -87,6 +107,10 @@ func (d *dbBasePostgres) HasReturningID(mi *modelInfo, query *string) (has bool)
return
}
func (d *dbBasePostgres) DbTypes() map[string]string {
return postgresTypes
}
func newdbBasePostgres() dbBaser {
b := new(dbBasePostgres)
b.ins = b