You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the existing issues and discussions.
Problem Description
Each SQL provider's specifics are spread across switch statements in storage/sql.go. Adding a provider means editing all of them, plus a new Lucene dialect file:
Function
Provider-specific part
OpenConnection
building the connection (DSN)
CreateSchema
skipping schema creation on SQLite
CreateMigrationTable
a different table definition for each provider
UpdateMigrationTable
SQLite vs. everything else
GetLatestMigration
SQLite vs. everything else
The default branches make it easy to cover a provider by accident. For example, CreateMigrationTable creates migrations on MySQL, while UpdateMigrationTable and GetLatestMigration use <schema>.migrations. Not verified against MySQL yet.
Desired Solution you'd like
Use the same pattern as storage/search/lucene/dialect.go: one private interface, one file per provider, one lookup table.
Check Existing Issues
Problem Description
Each SQL provider's specifics are spread across
switchstatements instorage/sql.go. Adding a provider means editing all of them, plus a new Lucene dialect file:OpenConnectionCreateSchemaCreateMigrationTableUpdateMigrationTableGetLatestMigrationThe
defaultbranches make it easy to cover a provider by accident. For example,CreateMigrationTablecreatesmigrationson MySQL, whileUpdateMigrationTableandGetLatestMigrationuse<schema>.migrations. Not verified against MySQL yet.Desired Solution you'd like
Use the same pattern as
storage/search/lucene/dialect.go: one private interface, one file per provider, one lookup table.sql_postgres.go,sql_mysql.go,sql_sqlite.gohold the provider code.postgresDSN/mysqlDSNfrom fix(storage/sql): escape connection string values #265 move there as-is.SQLAdapterlooks up its provider once inOpenConnection, and the switches become method calls.Keep it private: an exported registry would be new API that nobody needs yet. Use an explicit map, not
init()registration.Additional Context
sql.go.