1- package qb
1+ package sqlite3
22
33import (
44 "fmt"
@@ -8,75 +8,75 @@ import (
88 "github.com/slicebit/qb"
99)
1010
11- // SqliteDialect is a type of dialect that can be used with sqlite driver
12- type SqliteDialect struct {
11+ // Dialect is a type of dialect that can be used with sqlite driver
12+ type Dialect struct {
1313 escaping bool
1414}
1515
16- // NewSqliteDialect instanciate a SqliteDialect
17- func NewSqliteDialect () qb.Dialect {
18- return & SqliteDialect {false }
16+ // NewDialect creates a new sqlite3 dialect
17+ func NewDialect () qb.Dialect {
18+ return & Dialect {false }
1919}
2020
2121func init () {
22- qb .RegisterDialect ("sqlite3" , NewSqliteDialect )
23- qb .RegisterDialect ("sqlite" , NewSqliteDialect )
22+ qb .RegisterDialect ("sqlite3" , NewDialect )
23+ qb .RegisterDialect ("sqlite" , NewDialect )
2424}
2525
2626// CompileType compiles a type into its DDL
27- func (d * SqliteDialect ) CompileType (t qb.TypeElem ) string {
27+ func (d * Dialect ) CompileType (t qb.TypeElem ) string {
2828 if t .Name == "UUID" {
2929 return "VARCHAR(36)"
3030 }
3131 return qb .DefaultCompileType (t , d .SupportsUnsigned ())
3232}
3333
3434// Escape wraps the string with escape characters of the dialect
35- func (d * SqliteDialect ) Escape (str string ) string {
35+ func (d * Dialect ) Escape (str string ) string {
3636 if d .escaping {
3737 return fmt .Sprintf (`"%s"` , str )
3838 }
3939 return str
4040}
4141
4242// EscapeAll wraps all elements of string array
43- func (d * SqliteDialect ) EscapeAll (strings []string ) []string {
43+ func (d * Dialect ) EscapeAll (strings []string ) []string {
4444 return qb .EscapeAll (d , strings [0 :])
4545}
4646
4747// SetEscaping sets the escaping parameter of dialect
48- func (d * SqliteDialect ) SetEscaping (escaping bool ) {
48+ func (d * Dialect ) SetEscaping (escaping bool ) {
4949 d .escaping = escaping
5050}
5151
5252// Escaping gets the escaping parameter of dialect
53- func (d * SqliteDialect ) Escaping () bool {
53+ func (d * Dialect ) Escaping () bool {
5454 return d .escaping
5555}
5656
5757// AutoIncrement generates auto increment sql of current dialect
58- func (d * SqliteDialect ) AutoIncrement (column * qb.ColumnElem ) string {
58+ func (d * Dialect ) AutoIncrement (column * qb.ColumnElem ) string {
5959 if ! column .Options .InlinePrimaryKey {
6060 panic ("Sqlite does not support non-primarykey autoincrement columns" )
6161 }
6262 return "INTEGER PRIMARY KEY"
6363}
6464
6565// SupportsUnsigned returns whether driver supports unsigned type mappings or not
66- func (d * SqliteDialect ) SupportsUnsigned () bool { return false }
66+ func (d * Dialect ) SupportsUnsigned () bool { return false }
6767
6868// Driver returns the current driver of dialect
69- func (d * SqliteDialect ) Driver () string {
69+ func (d * Dialect ) Driver () string {
7070 return "sqlite3"
7171}
7272
7373// GetCompiler returns a SqliteCompiler
74- func (d * SqliteDialect ) GetCompiler () qb.Compiler {
74+ func (d * Dialect ) GetCompiler () qb.Compiler {
7575 return SqliteCompiler {qb .NewSQLCompiler (d )}
7676}
7777
7878// WrapError wraps a native error in a qb Error
79- func (d * SqliteDialect ) WrapError (err error ) qb.Error {
79+ func (d * Dialect ) WrapError (err error ) qb.Error {
8080 qbErr := qb.Error {Orig : err }
8181 sErr , ok := err .(sqlite3.Error )
8282 if ! ok {
0 commit comments