Skip to content

Commit 350391f

Browse files
committed
fix: correct database type handling and SQLite configuration
Critical fixes for PostgreSQL, SQLite, and CockroachDB: - Changed Postgres constant from 'psql' to 'postgres' (kept 'psql' as alias) - Fixed SQLite config: 'host' -> 'database' in test workflow - Updated getDriver() and buildConnectionString() to handle both 'postgres' and 'psql' - Ensures proper database connections and table creation This fixes the 'relation does not exist' errors by ensuring: 1. PostgreSQL/CockroachDB use correct connection strings 2. SQLite writes to correct database file
1 parent 170c5ed commit 350391f

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

.github/workflows/test-databases.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ jobs:
255255
.github/workflows/test-schema.json \
256256
<(echo '{
257257
"dbtype": "sqlite",
258-
"host": "test.db"
258+
"database": "test.db"
259259
}') \
260260
> test-schema.json
261261

golang/database.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func getDriver(dbType DbType) string {
4949
switch dbType {
5050
case MySQL, MariaDB:
5151
return "mysql"
52-
case Postgres, CockroachDB:
52+
case Postgres, PostgresAlt, CockroachDB:
5353
return "postgres"
5454
case SQLite:
5555
return "sqlite3"
@@ -66,7 +66,7 @@ func buildConnectionString(opts DbOptions) string {
6666
case MySQL, MariaDB:
6767
return fmt.Sprintf("%s:%s@tcp(%s)/%s?parseTime=true",
6868
opts.Username, opts.Password, opts.Host, opts.Database)
69-
case Postgres, CockroachDB:
69+
case Postgres, PostgresAlt, CockroachDB:
7070
return fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=disable",
7171
opts.Username, opts.Password, opts.Host, opts.Database)
7272
case SQLite:

golang/schema.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ type DbType string
1111

1212
const (
1313
MySQL DbType = "mysql"
14-
Postgres DbType = "psql"
14+
Postgres DbType = "postgres"
15+
PostgresAlt DbType = "psql" // Alternative name for backwards compatibility
1516
SQLite DbType = "sqlite"
1617
MSSQL DbType = "mssql"
1718
MariaDB DbType = "mariadb"

0 commit comments

Comments
 (0)