gofr-dev/gofr · error
unsupported db dialect; supported dialects are - mysql, post
Error message
unsupported db dialect; supported dialects are - mysql, postgres, supabase, sqlite, %s
What it means
errUnsupportedDialect is returned when the Dialect field of DBConfig is not one of the SQL dialects gofr supports: mysql, postgres, supabase, sqlite, or cockroachdb. NewSQL validates the dialect before building a connection string and refuses to construct a driver for anything unrecognized. It is a configuration-time error, not a runtime query error.
Source
Thrown at pkg/gofr/datasource/sql/sql.go:38
"gofr.dev/pkg/gofr/config"
"gofr.dev/pkg/gofr/datasource"
)
const (
sqlite = "sqlite"
cockroachDB = "cockroachdb"
defaultDBPort = 3306
requireSSLMode = "require"
tlsSkipVerify = "tls=skip-verify"
sslModeDisable = "disable"
sslModeVerifyCA = "verify-ca"
sslModeVerifyFull = "verify-full"
tlsCustom = "tls=custom"
localhost = "localhost"
)
var (
errUnsupportedDialect = fmt.Errorf(
"unsupported db dialect; supported dialects are - mysql, postgres, supabase, sqlite, %s", cockroachDB)
errFailedCACerts = fmt.Errorf("failed to append CA certificate")
)
// DBConfig has those members which are necessary variables while connecting to database.
type DBConfig struct {
Dialect string
HostName string
User string
Password string
Port string
Database string
SSLMode string
MaxIdleConn int
MaxOpenConn int
Charset string
}
View on GitHub (pinned to 187eb24962)
Solutions
- Set Dialect to one of: mysql, postgres, supabase, sqlite, cockroachdb (exact lowercase spelling).
- Check the DB_DIALECT environment variable for typos or extra whitespace.
- If using an unsupported engine, switch to a gofr-supported database or use a raw driver outside gofr's datasource layer.
Example fix
// before
cfg := sql.DBConfig{Dialect: "MySQL", HostName: "localhost"}
// after
cfg := sql.DBConfig{Dialect: "mysql", HostName: "localhost"} Defensive patterns
Strategy: validation
Validate before calling
supported := map[string]bool{"mysql": true, "postgres": true, "supabase": true, "sqlite": true, "cockroachdb": true}
if !supported[strings.ToLower(cfg.Dialect)] {
return fmt.Errorf("dialect %q not supported", cfg.Dialect)
} Prevention
- Keep dialect strings in one constants file and reference them instead of raw literals.
- Lowercase/trim DB_DIALECT env values before use.
- Add a startup smoke test that connects with the configured dialect in CI.
When it happens
Trigger: Calling gofr.NewSQL with a DBConfig whose Dialect is misspelled, empty, or an unsupported engine (e.g. "mssql", "orcale", "MySQL" with different casing) — the dialect switch in NewSQL/getDBConnectionString falls through to the default case.
Common situations: Typo in the DIALect env value, using uppercase or mixed-case dialect names, pointing an app at a database engine gofr doesn't wrap (SQL Server, Oracle), or copying config from another framework that uses different dialect identifiers.
Related errors
- sql: %w
- %w: deleting document: %w
- errors.Wrap(e.Err, e.Message).Error()
- invalid Azure configuration: share name is required
- invalid Azure configuration: account name is required
AI-assisted analysis of gofr-dev/gofr@187eb24962 (2026-09-01).
Data as JSON: /api/errors/cbd76444d417941a.
Report an issue: GitHub.