2013-07-30 12:32:38 +00:00
|
|
|
package orm
|
|
|
|
|
2013-08-10 16:15:26 +00:00
|
|
|
var mysqlOperators = map[string]string{
|
|
|
|
"exact": "= ?",
|
|
|
|
"iexact": "LIKE ?",
|
|
|
|
"contains": "LIKE BINARY ?",
|
|
|
|
"icontains": "LIKE ?",
|
|
|
|
// "regex": "REGEXP BINARY ?",
|
|
|
|
// "iregex": "REGEXP ?",
|
|
|
|
"gt": "> ?",
|
|
|
|
"gte": ">= ?",
|
|
|
|
"lt": "< ?",
|
|
|
|
"lte": "<= ?",
|
|
|
|
"startswith": "LIKE BINARY ?",
|
|
|
|
"endswith": "LIKE BINARY ?",
|
|
|
|
"istartswith": "LIKE ?",
|
|
|
|
"iendswith": "LIKE ?",
|
|
|
|
}
|
|
|
|
|
2013-08-19 14:37:39 +00:00
|
|
|
var mysqlTypes = map[string]string{
|
|
|
|
"auto": "AUTO_INCREMENT NOT NULL PRIMARY KEY",
|
|
|
|
"pk": "NOT NULL PRIMARY KEY",
|
|
|
|
"bool": "bool",
|
|
|
|
"string": "varchar(%d)",
|
|
|
|
"string-text": "longtext",
|
|
|
|
"time.Time-date": "date",
|
|
|
|
"time.Time": "datetime",
|
|
|
|
"int8": "tinyint",
|
|
|
|
"int16": "smallint",
|
|
|
|
"int32": "integer",
|
|
|
|
"int64": "bigint",
|
|
|
|
"uint8": "tinyint unsigned",
|
|
|
|
"uint16": "smallint unsigned",
|
|
|
|
"uint32": "integer unsigned",
|
|
|
|
"uint64": "bigint unsigned",
|
|
|
|
"float64": "double precision",
|
|
|
|
"float64-decimal": "numeric(%d, %d)",
|
|
|
|
}
|
|
|
|
|
2013-07-30 12:32:38 +00:00
|
|
|
type dbBaseMysql struct {
|
|
|
|
dbBase
|
|
|
|
}
|
|
|
|
|
2013-08-10 16:15:26 +00:00
|
|
|
var _ dbBaser = new(dbBaseMysql)
|
|
|
|
|
|
|
|
func (d *dbBaseMysql) OperatorSql(operator string) string {
|
|
|
|
return mysqlOperators[operator]
|
2013-07-30 12:32:38 +00:00
|
|
|
}
|
|
|
|
|
2013-08-19 14:37:39 +00:00
|
|
|
func (d *dbBaseMysql) DbTypes() map[string]string {
|
|
|
|
return mysqlTypes
|
|
|
|
}
|
|
|
|
|
2013-07-30 12:32:38 +00:00
|
|
|
func newdbBaseMysql() dbBaser {
|
|
|
|
b := new(dbBaseMysql)
|
|
|
|
b.ins = b
|
|
|
|
return b
|
|
|
|
}
|