2013-07-03 03:49:29 +00:00
|
|
|
// Copyright 2013 The XORM Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// Package xorm provides is a simple and powerful ORM for Go. It makes your
|
|
|
|
// database operation simple.
|
|
|
|
|
2013-06-04 08:56:59 +00:00
|
|
|
package xorm
|
|
|
|
|
|
|
|
import "strconv"
|
|
|
|
|
|
|
|
type mysql struct {
|
|
|
|
}
|
|
|
|
|
2013-07-03 03:49:29 +00:00
|
|
|
func (db *mysql) SqlType(c *Column) string {
|
2013-08-08 05:24:38 +00:00
|
|
|
var res string
|
2013-06-04 08:56:59 +00:00
|
|
|
switch t := c.SQLType; t {
|
2013-08-08 05:24:38 +00:00
|
|
|
case Bool:
|
|
|
|
res = TinyInt.Name
|
|
|
|
case Serial:
|
|
|
|
c.IsAutoIncrement = true
|
|
|
|
res = Int.Name
|
|
|
|
case BigSerial:
|
|
|
|
c.IsAutoIncrement = true
|
|
|
|
res = Integer.Name
|
|
|
|
case Bytea:
|
|
|
|
res = Blob.Name
|
2013-06-04 08:56:59 +00:00
|
|
|
default:
|
2013-08-08 05:24:38 +00:00
|
|
|
res = t.Name
|
2013-06-04 08:56:59 +00:00
|
|
|
}
|
2013-08-08 05:24:38 +00:00
|
|
|
|
|
|
|
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
|
2013-06-04 08:56:59 +00:00
|
|
|
}
|
2013-07-03 03:49:29 +00:00
|
|
|
|
|
|
|
func (db *mysql) SupportInsertMany() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2013-08-08 05:24:38 +00:00
|
|
|
func (db *mysql) QuoteStr() string {
|
2013-07-03 03:49:29 +00:00
|
|
|
return "`"
|
|
|
|
}
|
|
|
|
|
2013-08-08 05:24:38 +00:00
|
|
|
func (db *mysql) AutoIncrStr() string {
|
2013-07-03 03:49:29 +00:00
|
|
|
return "AUTO_INCREMENT"
|
|
|
|
}
|
2013-08-08 05:24:38 +00:00
|
|
|
|
|
|
|
func (db *mysql) SupportEngine() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (db *mysql) SupportCharset() bool {
|
|
|
|
return true
|
|
|
|
}
|