Skip to content
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

[MySQL] Query: Named arg is null or in slice caused Postgres import #3783

Open
terwey opened this issue Jan 12, 2025 · 0 comments
Open

[MySQL] Query: Named arg is null or in slice caused Postgres import #3783

terwey opened this issue Jan 12, 2025 · 0 comments
Labels
📚 mysql bug Something isn't working 💻 darwin

Comments

@terwey
Copy link

terwey commented Jan 12, 2025

Version

1.27.0

What happened?

When a query checks if a sqlc.narg is null OR in a sqlc.slice it causes "github.com/lib/pq" to be imported.
Simply id IN (sqlc.slice('author_ids') does not.

Relevant log output

No response

Database schema

CREATE TABLE authors (
  id   BIGINT  NOT NULL AUTO_INCREMENT PRIMARY KEY,
  name text    NOT NULL,
  bio  text
);

SQL queries

-- name: CausesPgToBeImported :many
SELECT 
    id AS author_id,
    name AS author_name,
    bio AS author_bio
FROM 
    authors
WHERE 
    (sqlc.narg('author_ids') IS NULL OR id IN (sqlc.slice('author_ids')));

Configuration

version: "2"
sql:
  - engine: "mysql"
    queries: "query.sql"
    schema: "schema.sql"
    gen:
      go:
        package: "tutorial"
        out: "tutorial"

Playground URL

https://play.sqlc.dev/p/0393067265d4e28076917f8b00b10e81d231a95ca79cdf222cf8ed61de62bffa

What operating system are you using?

macOS

What database engines are you using?

MySQL

What type of code are you generating?

Go

@terwey terwey added the bug Something isn't working label Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 mysql bug Something isn't working 💻 darwin
Projects
None yet
Development

No branches or pull requests

1 participant