xorm/sqlite3.go

72 lines
1.7 KiB
Go
Raw Normal View History

package xorm
type sqlite3 struct {
}
func (db *sqlite3) Init(uri string) error {
return nil
}
func (db *sqlite3) SqlType(c *Column) string {
2013-08-08 16:03:33 +00:00
switch t := c.SQLType.Name; t {
case Date, DateTime, TimeStamp, Time:
2013-08-08 16:03:33 +00:00
return Numeric
case Char, Varchar, TinyText, Text, MediumText, LongText:
2013-08-08 16:03:33 +00:00
return Text
case Bit, TinyInt, SmallInt, MediumInt, Int, Integer, BigInt, Bool:
2013-08-08 16:03:33 +00:00
return Integer
case Float, Double, Real:
2013-08-08 16:03:33 +00:00
return Real
case Decimal, Numeric:
2013-08-08 16:03:33 +00:00
return Numeric
case TinyBlob, Blob, MediumBlob, LongBlob, Bytea, Binary, VarBinary:
2013-08-08 16:03:33 +00:00
return Blob
case Serial, BigSerial:
2013-08-08 16:03:33 +00:00
c.IsPrimaryKey = true
c.IsAutoIncrement = true
2013-08-08 16:03:33 +00:00
c.Nullable = false
return Integer
default:
2013-08-08 16:03:33 +00:00
return t
}
}
func (db *sqlite3) SupportInsertMany() bool {
return true
}
func (db *sqlite3) QuoteStr() string {
return "`"
}
func (db *sqlite3) AutoIncrStr() string {
return "AUTOINCREMENT"
}
func (db *sqlite3) SupportEngine() bool {
return false
}
func (db *sqlite3) SupportCharset() bool {
return false
}
2013-09-26 07:19:39 +00:00
func (db *sqlite3) IndexOnTable() bool {
return false
}
func (db *sqlite3) IndexCheckSql(tableName, idxName string) (string, []interface{}) {
args := []interface{}{idxName}
return "SELECT name FROM sqlite_master WHERE type='index' and name = ?", args
}
func (db *sqlite3) TableCheckSql(tableName string) (string, []interface{}) {
args := []interface{}{tableName}
return "SELECT name FROM sqlite_master WHERE type='table' and name = ?", args
}
func (db *sqlite3) ColumnCheckSql(tableName, colName string) (string, []interface{}) {
args := []interface{}{tableName}
return "SELECT name FROM sqlite_master WHERE type='table' and name = ? and sql like '%`" + colName + "`%'", args
}