xorm/postgres.go

67 lines
1.2 KiB
Go
Raw Normal View History

package xorm
import "strconv"
type postgres struct {
}
func (db *postgres) SqlType(c *Column) string {
var res string
2013-08-08 16:03:33 +00:00
switch t := c.SQLType.Name; t {
case TinyInt:
2013-08-08 16:03:33 +00:00
res = SmallInt
case MediumInt, Int, Integer:
2013-08-08 16:03:33 +00:00
return Integer
case Serial, BigSerial:
c.IsAutoIncrement = true
2013-08-08 16:03:33 +00:00
c.Nullable = false
res = t
case Binary, VarBinary:
2013-08-08 16:03:33 +00:00
return Bytea
case DateTime:
2013-08-08 16:03:33 +00:00
res = TimeStamp
case Float:
2013-08-08 16:03:33 +00:00
res = Real
case TinyText, MediumText, LongText:
2013-08-08 16:03:33 +00:00
res = Text
case Blob, TinyBlob, MediumBlob, LongBlob:
2013-08-08 16:03:33 +00:00
return Bytea
case Double:
return "DOUBLE PRECISION"
default:
if c.IsAutoIncrement {
2013-08-08 16:03:33 +00:00
return Serial
}
2013-08-08 16:03:33 +00:00
res = t
}
var hasLen1 bool = (c.Length > 0)
var hasLen2 bool = (c.Length2 > 0)
if hasLen1 {
res += "(" + strconv.Itoa(c.Length) + ")"
} else if hasLen2 {
res += "(" + strconv.Itoa(c.Length) + "," + strconv.Itoa(c.Length2) + ")"
}
return res
}
func (db *postgres) SupportInsertMany() bool {
return true
}
func (db *postgres) QuoteStr() string {
return "\""
}
func (db *postgres) AutoIncrStr() string {
return ""
}
func (db *postgres) SupportEngine() bool {
return false
}
func (db *postgres) SupportCharset() bool {
return false
}