Changeset 0.17.1 (#76)
This commit is contained in:
31
server/database/dialect.go
Normal file
31
server/database/dialect.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package database
|
||||
|
||||
// Dialect identifies the active database backend.
|
||||
type Dialect int
|
||||
|
||||
const (
|
||||
DialectPostgres Dialect = iota
|
||||
DialectSQLite
|
||||
)
|
||||
|
||||
// CurrentDialect is set during Connect() and read by store constructors
|
||||
// to select the appropriate SQL flavour.
|
||||
var CurrentDialect Dialect
|
||||
|
||||
// String returns a human-readable label.
|
||||
func (d Dialect) String() string {
|
||||
switch d {
|
||||
case DialectPostgres:
|
||||
return "postgres"
|
||||
case DialectSQLite:
|
||||
return "sqlite"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
|
||||
// IsPostgres returns true when connected to PostgreSQL.
|
||||
func IsPostgres() bool { return CurrentDialect == DialectPostgres }
|
||||
|
||||
// IsSQLite returns true when connected to SQLite.
|
||||
func IsSQLite() bool { return CurrentDialect == DialectSQLite }
|
||||
Reference in New Issue
Block a user