sqlc-dev / sqlc

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

Boolean filter generation fails for SQLite #2424

Closed SoMuchForSubtlety closed 1 year ago

SoMuchForSubtlety commented 1 year ago

Version

1.18.0

What happened?

Boolean filter expressions don't seem to get processed correctly. I can get it to work by changing the query slightly, but then I lose type information.

Relevant log output

No response

Database schema

create table my_table
(
    invalid boolean,
    foo     varchar
);

SQL queries

-- name: GetData :many
select *
from my_table
where (cast(sqlc.arg(allow_invalid) as boolean) or not invalid);

Configuration

No response

Playground URL

https://play.sqlc.dev/p/80e82864f4994ee1812495bbdfa2bd351fdfa43f1a15968dc61d192e79b22e28

What operating system are you using?

Linux

What database engines are you using?

SQLite

What type of code are you generating?

Go

andrewmbenton commented 1 year ago

Looks like we are at the very least not correctly handling the cast node correctly