sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

SQLite cannot use an empty slice for `NOT IN`

Open Evan-Prophet opened this issue 1 year ago • 0 comments

Version

1.26.0

What happened?

When using NOT IN & SQLite, if you pass it an empty slice, it will never match. This is because of:

query = strings.Replace(query, "/*SLICE:userIDs*/?", "NULL", 1)

The replacement to NULL will never be true.

E.g.:

# No Results
select "example" as example WHERE example NOT IN (NULL);

# Results
select "example" as example WHERE example NOT IN ();

Relevant log output

No response

Database schema

No response

SQL queries

No response

Configuration

No response

Playground URL

https://play.sqlc.dev/p/1e688f1a8a0033e2e2bbbc3c0621e541cd11ef25a8ccd20aedcdd36d918892fa

What operating system are you using?

macOS

What database engines are you using?

SQLite

What type of code are you generating?

Go

Evan-Prophet avatar Jun 17 '24 15:06 Evan-Prophet