sqlc
sqlc copied to clipboard
PostGIS breaks with database configuration
Version
1.27.0
What happened?
When no database is set in sqlc.json, this generates valid code that works:
INSERT INTO t (location) VALUES (ST_GeomFromEWKB(@location));
This produces the following output, using my override:
type T struct {
Location postgis.PointS `db:"location" json:"location"`
}
However as soon as a database is set in sqlc.json, that same code results in:
cannot use postgis.PointS{…} (value of type postgis.PointS) as []byte value in struct literal
This is because the generated struct now has Location interface{}, ignoring my override.
I'd like to be able to use sqlc vet against my actual database but I wouldn't expect it to change the output of the generated code if my migrations produce that exact same database reliably.
Relevant log output
No response
Database schema
Column | Type | Collation | Nullable | Default
-----------------+----------------------+-----------+----------+------------------------------
location | geometry(Point,4326) | | not null |
SQL queries
INSERT INTO my_table (location) VALUES (ST_GeomFromEWKB(@location));
Configuration
{
"version": 2,
"sql": [
{
"schema": "app/postgres/migrations",
"queries": "app/postgres/queries",
"engine": "postgresql",
"database": {
"uri": "postgresql://postgres:password@localhost:5432/mydb"
},
"rules": ["sqlc/db-prepare"],
"gen": {
"go": {
"package": "repo",
"sql_package": "pgx/v5",
"out": "app/postgres/repo",
"emit_all_enum_values": true,
"emit_db_tags": true,
"emit_empty_slices": true,
"emit_enum_valid_method": true,
"emit_json_tags": true,
"json_tags_case_style": "camel",
"overrides": [
{
"column": "t.location",
"go_type": "github.com/cridenour/go-postgis.PointS"
}
]
}
}
}
]
}
Playground URL
No response
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go