sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

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

Open trevorstarick opened this issue 3 years ago • 2 comments

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

trevorstarick avatar Sep 01 '22 20:09 trevorstarick

Having same issue

nismayil avatar Sep 07 '22 07:09 nismayil

Having same issue

silver-brother avatar Sep 21 '22 01:09 silver-brother

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

TachiuLam avatar Dec 13 '22 09:12 TachiuLam

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

orisano avatar Jul 26 '23 07:07 orisano