67 lines
1.2 KiB
Go
67 lines
1.2 KiB
Go
// 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.
|
|
|
|
package xorm
|
|
|
|
import (
|
|
"strconv"
|
|
)
|
|
|
|
type mysql struct {
|
|
}
|
|
|
|
func (db *mysql) SqlType(c *Column) string {
|
|
var res string
|
|
switch t := c.SQLType.Name; t {
|
|
case Bool:
|
|
res = TinyInt
|
|
case Serial:
|
|
c.IsAutoIncrement = true
|
|
c.IsPrimaryKey = true
|
|
c.Nullable = false
|
|
res = Int
|
|
case BigSerial:
|
|
c.IsAutoIncrement = true
|
|
c.IsPrimaryKey = true
|
|
c.Nullable = false
|
|
res = BigInt
|
|
case Bytea:
|
|
res = Blob
|
|
default:
|
|
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 *mysql) SupportInsertMany() bool {
|
|
return true
|
|
}
|
|
|
|
func (db *mysql) QuoteStr() string {
|
|
return "`"
|
|
}
|
|
|
|
func (db *mysql) AutoIncrStr() string {
|
|
return "AUTO_INCREMENT"
|
|
}
|
|
|
|
func (db *mysql) SupportEngine() bool {
|
|
return true
|
|
}
|
|
|
|
func (db *mysql) SupportCharset() bool {
|
|
return true
|
|
}
|