From: david wheeler <hippysoyboy@gmail.com>
To: pgsql-general@postgresql.org
Subject: IS as a binary operator
Date: Sat, 25 Feb 2023 21:38:38 +1100
Message-ID: <4996BD98-0349-4871-B952-AFD8261920D0@gmail.com> (raw)
Heya folks,
Recently I've been using a Kotlin library SQLDelight <https://cashapp.github.io/sqldelight/2.0.0-alpha05/; which is great but has some issues with PostgreSQL support. In particular, for null parameters it converts `=` to `IS` - and it treats `IS` as a binary operator (rather than `IS NULL` unary operator), which Postgres doesn't like wrt prepared statements
prepare test(text) as (SELECT * FROM test WHERE nullable_col IS $1);
ERROR: syntax error at or near "$1"
LINE 1: ...epare test(text) as (SELECT * FROM test WHERE nullable_col IS $1);
full details at [1]
I’ve been working on a PR to use `IS NOT DISTINCT FROM` as the `=` substitution for nullable parameters rather than `IS`, however unfortunately that’s not universally supported either (MySQL).
Just wondering if anyone has other ideas? I guess there’s no interest in adding support for `IS` as basically an alias for `IS NOT DISTINCT FROM`? (and `IS NOT` for `IS DISTINCT FROM`)
TIA
David Wheeler
[1] https://github.com/cashapp/sqldelight/issues/3863
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: hippysoyboy@gmail.com
Subject: Re: IS as a binary operator
In-Reply-To: <4996BD98-0349-4871-B952-AFD8261920D0@gmail.com>
References: <4996BD98-0349-4871-B952-AFD8261920D0@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox