From: Daniele Varrazzo Date: Wed, 30 Oct 2024 14:44:29 +0000 (+0100) Subject: docs: further wordsmith around IS/DISTINCT X-Git-Tag: 3.2.4~32^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F940%2Fhead;p=thirdparty%2Fpsycopg.git docs: further wordsmith around IS/DISTINCT Also restore lost link reference. --- diff --git a/docs/basic/from_pg2.rst b/docs/basic/from_pg2.rst index ef78bb381..7fb94d92f 100644 --- a/docs/basic/from_pg2.rst +++ b/docs/basic/from_pg2.rst @@ -270,8 +270,8 @@ You cannot use :sql:`IS %s` or :sql:`IS NOT %s`:: LINE 1: SELECT * FROM foo WHERE field IS $1 ^ -This is probably caused by the fact that :sql:`IS` is not a binary operator in -PostgreSQL; rather, :sql:`IS NULL` and :sql:`IS NOT NULL` are unary operators +This is probably caused by the fact that :sql:`IS` is not a binary predicate in +PostgreSQL; rather, :sql:`IS NULL` and :sql:`IS NOT NULL` are unary predicates and you cannot use :sql:`IS` with anything else on the right hand side. Testing in psql: @@ -279,11 +279,12 @@ Testing in psql: =# SELECT 10 IS 10; ERROR: syntax error at or near "10" - LINE 1: select 10 is 10; + LINE 1: SELECT 10 IS 10; ^ -What you can do instead is to use :sql:`IS NOT DISTINCT FROM %s` in place of -:sql:`IS %s` (please pay attention to the awkwardly reversed :sql:`NOT`):: +What you can do is to use `IS [NOT] DISTINCT FROM`__ predicate instead: +:sql:`IS NOT DISTINCT FROM %s` can be used in place of :sql:`IS %s` (please +pay attention to the awkwardly reversed :sql:`NOT`):: >>> conn.execute("SELECT * FROM foo WHERE field IS NOT DISTINCT FROM %s", [None])