Skip to content

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

Closed
@ludusrusso

Description

@ludusrusso

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions