Files
kubesphere/vendor/github.com/gocraft/dbr/dialect/sqlite3.go
runzexia 5a6f51d775 devops tenant api
Signed-off-by: runzexia <runzexia@yunify.com>
2019-04-24 17:35:31 +08:00

41 lines
734 B
Go

package dialect
import (
"fmt"
"strings"
"time"
)
type sqlite3 struct{}
func (d sqlite3) QuoteIdent(s string) string {
return quoteIdent(s, `"`)
}
func (d sqlite3) EncodeString(s string) string {
// https://www.sqlite.org/faq.html
return `'` + strings.Replace(s, `'`, `''`, -1) + `'`
}
func (d sqlite3) EncodeBool(b bool) string {
// https://www.sqlite.org/lang_expr.html
if b {
return "1"
}
return "0"
}
func (d sqlite3) EncodeTime(t time.Time) string {
// https://www.sqlite.org/lang_datefunc.html
return MySQL.EncodeTime(t)
}
func (d sqlite3) EncodeBytes(b []byte) string {
// https://www.sqlite.org/lang_expr.html
return fmt.Sprintf(`X'%x'`, b)
}
func (d sqlite3) Placeholder(_ int) string {
return "?"
}