Skip to content

Commit bdb4e57

Browse files
committed
codegen/golang: name the engines with constants; ci: build the end-to-end module with cgo
The end-to-end module is one of its own, so cgo there is no concern of sqlc's builds, and the DuckDB golden compiles with the rest again. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rfiHyC4iRLyRWc3UmYEtT
1 parent 6fc4352 commit bdb4e57

5 files changed

Lines changed: 25 additions & 16 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,11 @@ jobs:
4747
env:
4848
CGO_ENABLED: "0"
4949

50-
# The DuckDB golden imports the DuckDB driver, which is cgo, so it is
51-
# left out of this build and checked by the replay suite alone.
50+
# A module of its own, so cgo stays on for the DuckDB driver the
51+
# DuckDB golden imports.
5252
- name: build internal/endtoend
53-
run: go build $(go list ./... | grep -v '/core_types/duckdb/')
53+
run: go build ./...
5454
working-directory: internal/endtoend/testdata
55-
env:
56-
CGO_ENABLED: "0"
5755

5856
- name: install databases
5957
run: go run ./cmd/sqlc-test-setup install postgresql mysql

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test-examples:
2121
cd ./examples && go test --tags=examples ./...
2222

2323
build-endtoend:
24-
cd ./internal/endtoend/testdata && CGO_ENABLED=0 go build $$(go list ./... | grep -v '/core_types/duckdb/')
24+
cd ./internal/endtoend/testdata && go build ./...
2525

2626
test-ci: test-examples build-endtoend vet
2727

‎internal/codegen/golang/driver.go‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,24 @@ func parseDriver(sqlPackage string) opts.SQLDriver {
1313
}
1414
}
1515

16+
// The engines, as the request names them.
17+
const (
18+
engineClickHouse = "clickhouse"
19+
engineDuckDB = "duckdb"
20+
engineGoogleSQL = "googlesql"
21+
engineMSSQL = "mssql"
22+
engineMySQL = "mysql"
23+
enginePostgreSQL = "postgresql"
24+
engineSQLite = "sqlite"
25+
)
26+
1627
// usesPqArrays reports whether the queries pass array values through
1728
// pq.Array. That is how lib/pq reads and writes PostgreSQL arrays, so it
1829
// holds for PostgreSQL under database/sql; pgx and the other engines'
1930
// drivers scan a slice directly.
2031
func usesPqArrays(engine string, driver opts.SQLDriver) bool {
2132
switch engine {
22-
case "clickhouse", "duckdb", "googlesql", "mssql":
33+
case engineClickHouse, engineDuckDB, engineGoogleSQL, engineMSSQL:
2334
return false
2435
}
2536
return !driver.IsPGX()

‎internal/codegen/golang/go_type.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,19 @@ func goInnerType(req *plugin.GenerateRequest, options *opts.Options, col *plugin
9797

9898
// TODO: Extend the engine interface to handle types
9999
switch req.Settings.Engine {
100-
case "mysql":
100+
case engineMySQL:
101101
return mysqlType(req, options, col), false
102-
case "postgresql":
102+
case enginePostgreSQL:
103103
return postgresType(req, options, col), false
104-
case "sqlite":
104+
case engineSQLite:
105105
return sqliteType(req, options, col), false
106-
case "clickhouse":
106+
case engineClickHouse:
107107
return clickhouseType(req, options, col), true
108-
case "duckdb":
108+
case engineDuckDB:
109109
return duckdbType(req, options, col, param), true
110-
case "googlesql":
110+
case engineGoogleSQL:
111111
return googlesqlType(req, options, col), true
112-
case "mssql":
112+
case engineMSSQL:
113113
return mssqlType(req, options, col), true
114114
default:
115115
return "any", false

‎internal/codegen/golang/result.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,9 +496,9 @@ func placeholdersAreNamed(engine, text string, params []*plugin.Parameter) bool
496496
}
497497
var named bool
498498
switch engine {
499-
case "mssql", "googlesql":
499+
case engineMSSQL, engineGoogleSQL:
500500
named = strings.Contains(text, "@"+name)
501-
case "clickhouse":
501+
case engineClickHouse:
502502
named = strings.Contains(text, "{"+name+":")
503503
}
504504
if !named {

0 commit comments

Comments
 (0)