select * from users where age = @first + @second; -- broken
select * from users where age = @first - @second; -- broken
select * from users where age = @first * @second; -- broken
select * from users where age = @first / @second; -- broken
select * from users where age = @first % @second; -- broken
select * from users where age = @first ^ @second; -- broken
select * from users where age = @first |/ @second; -- works (also, TIL)
select * from users where age = @first ||/ @second; -- works
select * from users where age = @first ! @second; -- works
select * from users where age = @first !! @second; -- works
select * from users where age = @first @ @second; -- broken... hmmm...
select * from users where age = @first & @second; -- works
select * from users where age = @first | @second; -- works
select * from users where age = @first # @second; -- works
select * from users where age = @first ~ @second; -- works
select * from users where age = @first << @second; -- works
select * from users where age = @first >> @second; -- works
Version
1.27.0
What happened?
Let's start with what actually works:
Say we wanted the parameters to be named. This also works:
However, this breaks the parser:
Ok. We'll want to cast these named parameters anyway. So let's try that:
PC LOAD LETTER? What does that mean?
What if we mangle our SQL to get sqlc to work? (no stranger to that!)
We Did It™ 🎉
It seems like the parser doesn't like certain operators but handles others just fine. Let's go through a list of Postgres operators: https://www.postgresql.org/docs/7.4/functions-math.html
Relevant log output
No response
Database schema
No response
SQL queries
No response
Configuration
No response
Playground URL
No response
What operating system are you using?
No response
What database engines are you using?
No response
What type of code are you generating?
No response