Skip to content

Missing import for overrides #2304

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

Closed
tschaub opened this issue Jun 7, 2023 · 3 comments
Closed

Missing import for overrides #2304

tschaub opened this issue Jun 7, 2023 · 3 comments

Comments

@tschaub
Copy link

tschaub commented Jun 7, 2023

Version

1.18.0

What happened?

I upgraded from v1.12.0 to v1.18.0 and see that the generated code no longer includes imports for overrides in my sqlc.yaml.

Here is an example change in one of the generated files after upgrading:

diff --git a/gen/queries/publications.sql.go b/gen/queries/publications.sql.go
index 1b22458..c3d0253 100644
--- a/gen/queries/publications.sql.go
+++ b/gen/queries/publications.sql.go
@@ -1,4 +1,6 @@
 // Code generated by sqlc. DO NOT EDIT.
+// versions:
+//   sqlc v1.18.0
 // source: publications.sql
 
 package queries
@@ -8,7 +10,6 @@ import (
        "encoding/json"
        "time"
 
-       "example.com/mod/geo"
        "github.com/google/uuid"
        "github.com/lib/pq"
 )

Relevant log output

No response

Database schema

CREATE TABLE publications (
	id UUID PRIMARY KEY,
	title TEXT NOT NULL,
	abstract TEXT NOT NULL,
	publisher TEXT NOT NULL,
	date_published TIMESTAMP WITH TIME ZONE NOT NULL,
	geometry GEOMETRY NOT NULL,
	created TIMESTAMP WITH TIME ZONE NOT NULL,
	updated TIMESTAMP WITH TIME ZONE NOT NULL
);

CREATE INDEX ON publications USING GIST(geometry);
CREATE INDEX ON publications USING GIN(vector);
CREATE INDEX ON publications (created DESC);

SQL queries

-- name: CreatePublication :one
INSERT INTO publications (
  id, title, abstract, type, publisher, date_published, published, geometry, created, updated
) VALUES (
  sqlc.arg('id'),
  sqlc.arg('title'),
  sqlc.arg('abstract'),
  sqlc.arg('type'),
  sqlc.arg('publisher'),
  sqlc.arg('date_published'),
  sqlc.arg('published'),
  sqlc.arg('geometry'),
  sqlc.arg('created'),
  sqlc.arg('updated')
)
RETURNING *;

Configuration

version: "1"
packages:
  - name: "queries"
    emit_json_tags: true
    emit_prepared_queries: false
    emit_interface: true
    path: "gen/queries"
    schema: "./sql/schema/"
    queries: "./sql/queries/"
overrides:
  - db_type: "geometry"
    go_type: "*example.com/mod/geo.Geometry"

Playground URL

https://play.sqlc.dev/p/5677f36f5aafd936d7732c20ed2e0ed5bde9fb90fa6906d12477e00ea5c5143f

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@tschaub tschaub added bug Something isn't working triage New issues that hasn't been reviewed labels Jun 7, 2023
@kyleconroy kyleconroy added 📚 postgresql 🔧 golang 💻 darwin regression and removed triage New issues that hasn't been reviewed labels Jun 8, 2023
@kyleconroy kyleconroy added this to the v1.19.0 milestone Jun 9, 2023
@andrewmbenton
Copy link
Collaborator

Based on my testing I am seeing the correct imports when running a sqlc build from the main branch, which means it should be resolved with the next release.

I have turned this example into an endtoend test and will work on getting it added so that we catch this in the future.

@andrewmbenton
Copy link
Collaborator

After further inspection I believe the tests in internal/endtoend/testdata/overrides_pointers cover this. Those tests were introduced just after the last release.

So I think this is a duplicate of #2239. I will close for now but if you see this persist with either a build from main or after the next release please reopen.

@andrewmbenton andrewmbenton closed this as not planned Won't fix, can't repro, duplicate, stale Jun 20, 2023
@stepan-romankov
Copy link

stepan-romankov commented Jul 10, 2023

@andrewmbenton Bug is still present in 1.19

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

4 participants