sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

using :execresult and :batchexec causes invalid import in batch.go

Open jlisthood opened this issue 3 years ago • 0 comments

Version

1.14.0

What happened?

batch.go will import "github.com/jackc/pgconn" without using it if you use :execresult and :batchexec in the same query.sql file

Relevant log output

No response

Database schema

-- Example queries for sqlc
CREATE TABLE authors (
  id   BIGSERIAL PRIMARY KEY,
  name text      NOT NULL,
  bio  text
);

SQL queries

-- name: CreateAuthor :execresult
INSERT INTO authors (
  name, bio
) VALUES (
  $1, $2
);

-- name: BatchUpdateBio :batchexec
UPDATE authors
SET bio = $1
WHERE id = $2;

Configuration

{
  "version": "1",
  "packages": [
    {
      "path": "db",
      "engine": "postgresql",
      "schema": "query.sql",
      "queries": "query.sql",
      "sql_package": "pgx/v4",
    }
  ]
}
​

Playground URL

https://play.sqlc.dev/p/3669b609952d7561251d8991ad37a043ce0fdcb44c1dd9f8c927bc607aaec059

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

jlisthood avatar Jun 15 '22 21:06 jlisthood