Skip to content

Pointers overrides arguments still not imported properly in codegen in v1.18 #2239

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
ludusrusso opened this issue Apr 28, 2023 · 0 comments · Fixed by #2240
Closed

Pointers overrides arguments still not imported properly in codegen in v1.18 #2239

ludusrusso opened this issue Apr 28, 2023 · 0 comments · Fixed by #2240
Labels
bug Something isn't working

Comments

@ludusrusso
Copy link
Contributor

ludusrusso commented Apr 28, 2023

Version

1.18.0

What happened?

#2217 fixed pointer overrides imports in file model.go, but the same problem still exists where the import is required in queries generated file, e.g., in generated function args.

I'll fix it in a PR soon.

// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.18.0
// source: query.sql

package db

import (
	"context"

         // <- missing import t here
)

const test = `-- name: test :exec
UPDATE foo SET langs = $1
`

func (q *Queries) test(ctx context.Context, langs *t.Text) error {
	_, err := q.db.ExecContext(ctx, test, langs)
	return err
}

Relevant log output

No response

Database schema

CREATE TABLE foo (
    other     text NOT NULL,
    total     bigint NOT NULL,
    tags      text[] NOT NULL,
    byte_seq  bytea NOT NULL,
    retyped   text NOT NULL,
    langs     text[]
);

SQL queries

-- name: test :exec
UPDATE foo SET langs = $1;

Configuration

{
  "version": "1",
  "packages": [
    {
      "path": "go",
      "name": "override",
      "engine": "postgresql",
      "schema": "schema.sql",
      "queries": "query.sql",
      "overrides": [
        {
          "go_type": {
            "import": "github.com/jackc/pgtype",
            "type": "Text",
            "package": "t",
            "pointer": true
          },
          "column": "foo.langs"
        }
      ]
    }
  ]
}

Playground URL

https://play.sqlc.dev/p/d84fa60baac2c630ced0f988c11ee619f0f77dd2f6b38fc71679accbcd0d8255

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@ludusrusso ludusrusso added bug Something isn't working triage New issues that hasn't been reviewed labels Apr 28, 2023
@kyleconroy kyleconroy removed the triage New issues that hasn't been reviewed label Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants