Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostGIS breaks with database configuration #3632

Open
egtann opened this issue Oct 4, 2024 · 0 comments
Open

PostGIS breaks with database configuration #3632

egtann opened this issue Oct 4, 2024 · 0 comments

Comments

@egtann
Copy link
Contributor

egtann commented Oct 4, 2024

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

@egtann egtann added the bug Something isn't working label Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant