Skip to content

Missing import for overrides #2304

Closed as not planned
Closed as not planned
@tschaub

Description

@tschaub

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions