sqlc-dev / sqlc

Generate type-safe code from SQL
https://sqlc.dev
MIT License
13.38k stars 803 forks source link

sqlite: `WHERE ... IN (?)` generates query with no parameters #1829

Closed trevorstarick closed 1 year ago

trevorstarick commented 2 years ago

Version

1.15.0

What happened?

When generating a query using a WHERE ... IN (?) statement, I expected to get a function out that looked similar to func (q *Queries) Foo(ctx context.Context, in []interface{}) ([]string, error) but the in []interface{} parameter isn't included.

Current workaround is to export the query and then have sqlx handle it via it's support for in queries.

Relevant log output

No response

Database schema

CREATE TABLE foo (
    hash TEXT NOT NULL PRIMARY KEY
)

SQL queries

-- name: Foo :many
SELECT * FROM foo WHERE hash IN (?) LIMIT 50;

Configuration

version: 2
sql:
    - engine: "sqlite"
      schema: "schema.sql"
      queries: "queries.sql"
      gen:
        go:
            package: "example"
            out: "example"
            emit_db_tags: true
            emit_prepared_queries: true
            emit_exact_table_names: true
            emit_empty_slices: true
            emit_exported_queries: true
            emit_json_tags: true

Playground URL

https://play.sqlc.dev/p/91e8edaab2a3e8f4c48e79732e5243f827fd23a9d137ebff6d7fd12429b5d1d8

What operating system are you using?

Linux, macOS

What database engines are you using?

No response

What type of code are you generating?

Go

nismayil commented 2 years ago

Having same issue

silver-brother commented 2 years ago

Having same issue

TachiuLam commented 1 year ago

https://github.com/kyleconroy/sqlc/issues/77

orisano commented 1 year ago

This can now be achieved by using sqlc.slice. https://play.sqlc.dev/p/ed1b1d235f3a32c811a27dec68d826b4c0c36dedf0e614f0339fa02e11cc4ba4