|
I am currently trying to to use PostGIS Geometry Points in one of my tables for storing and querying points on a 2D plane, however, I cannot get it working. I've tried following the instructions here with sqlc.yaml version: "2"
sql:
- engine: "postgresql"
queries: "database/queries"
schema: "database/migrations"
gen:
go:
package: "gensql"
out: "database/gensql"
sql_package: "pgx/v5"
emit_pointers_for_null_types: true
emit_json_tags: true
json_tags_case_style: "camel"
overrides:
- db_type: "geometry"
go_type: "github.com/cridenour/go-postgis.Point"migration CREATE TABLE IF NOT EXISTS wallet
(
id BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
address TEXT NOT NULL UNIQUE,
code INT NOT NULL,
webhook TEXT,
location GEOMETRY(POINT),
created_at TIMESTAMPTZ NOT NULL
);query -- name: GetWallet :one
SELECT id, address, code, webhook, location::geometry, collateral_percentage, created_at FROM wallet WHERE id = $1;aRunning GetWallet I get the following error from PGX: My SQLC version is 1.28.0, my project is using Go 1.24.0, and my PGX version is v5.7.2. If I can think of any other relevant information I'll be sure to add it. Any help is greatly appreciated. |
Replies: 1 comment
|
It seems that SQLC wasn't recognizing in my migrations that it was the GEOMETRY type, and that it was nullable. My solution was to change my config to the following: version: "2"
sql:
- engine: "postgresql"
queries: "database/queries"
schema: "database/migrations"
gen:
go:
package: "gensql"
out: "database/gensql"
sql_package: "pgx/v5"
emit_pointers_for_null_types: true
emit_json_tags: true
json_tags_case_style: "camel"
overrides:
- db_type: "geometry"
go_type:
import: "github.com/cridenour/go-postgis"
package: "postgis"
pointer: true
type: "Point"
nullable: true |
It seems that SQLC wasn't recognizing in my migrations that it was the GEOMETRY type, and that it was nullable. My solution was to change my config to the following: