cayleygraph/cayley · error
unsupported sql database: %q
Error message
unsupported sql database: %q
What it means
Init registers and opens a SQL-backed quadstore. The SQL flavor must be one of the keys in the package's `types` map (postgres, mysql, sqlite). If the `typ` string passed in doesn't match any registered flavor, the store refuses to initialize and returns this error before attempting any connection.
Source
Thrown at graph/sql/quadstore.go:204
}
var nodeInsertColumns = [][]string{
{"value"},
{"value_string", "iri"},
{"value_string", "bnode"},
{"value_string"},
{"value_string", "datatype"},
{"value_string", "language"},
{"value_int"},
{"value_bool"},
{"value_float"},
{"value_time"},
}
func Init(typ string, addr string, options graph.Options) error {
fl, ok := types[typ]
if !ok {
return fmt.Errorf("unsupported sql database: %q", typ)
}
conn, err := connect(addr, fl.Driver, options)
if err != nil {
return err
}
defer conn.Close()
nodesSQL := fl.nodesTable()
quadsSQL := fl.quadsTable()
indexes := fl.quadIndexes(options)
if fl.NoSchemaChangesInTx {
_, err = conn.Exec(nodesSQL)
if err != nil {
err = fl.Error(err)
clog.Errorf("Cannot create nodes table: %v", err)
return err
}View on GitHub (pinned to 81dcd7d73e)
Solutions
- Check the spelling of the type argument against the supported list (postgres, mysql, sqlite)
- Fix the database/type field in the Cayley config or command-line flag to a supported value
- Inspect the types map in graph/sql/quadstore.go for the exact registered keys in your version
- Register a custom flavor by importing a driver package (e.g. _ "github.com/.../sql/postgres") if it exists
Example fix
// before
err := sql.Init("postgresql", addr, opts)
// after
err := sql.Init("postgres", addr, opts) Defensive patterns
Strategy: validation
Validate before calling
supported := []string{"postgres", "mysql", "sqlite"}
found := false
for _, s := range supported { if typ == s { found = true } }
if !found { return fmt.Errorf("unsupported sql type %q; supported: %v", typ, supported) } Prevention
- Keep the database type string in one config constant, not duplicated strings
- Validate config at startup before calling Init
- Check the types map for your exact library version
When it happens
Trigger: Calling graph/sql.Init with a backend name not in the types map, e.g. Init("postgresql", ...) when only "postgres" is registered, or a typo like "sqllite".
Common situations: Cayley config files where database: is set to a misspelled or renamed backend name; migrating from another triplestore whose driver names differ (e.g. "cockroach" vs "postgres"); upgrading versions where a flavor was removed.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- sql query failed: %v query: %v
- unsupported time format: %T: %v
- error executing value lookup: %w
- unmarshal value: %w
- HTTP Request needed
AI-assisted analysis of cayleygraph/cayley@81dcd7d73e (2026-09-06).
Data as JSON: /api/errors/c2b2cc25281102b1.
Report an issue: GitHub.