32 lines
735 B
Go
32 lines
735 B
Go
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 }
|