Skip to content

Commit

Permalink
Deploying to master from @ psycopg/psycopg-website@e879ef3 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
dvarrazzo committed Oct 30, 2024
1 parent 6492335 commit e7b2f80
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
11 changes: 6 additions & 5 deletions psycopg3/docs/_sources/basic/from_pg2.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -270,20 +270,21 @@ 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:

.. code:: text
=# 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 the `IS DISTINCT FROM operator`__, which
will gladly accept a placeholder::
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])

Expand Down
11 changes: 6 additions & 5 deletions psycopg3/docs/basic/from_pg2.html
Original file line number Diff line number Diff line change
Expand Up @@ -466,18 +466,19 @@
<span class="x"> ^</span>
</pre></div>
</div>
<p>This is probably caused by the fact that <code class="sql docutils literal notranslate"><span class="pre">IS</span></code> is not a binary operator in
PostgreSQL; rather, <code class="sql docutils literal notranslate"><span class="pre">IS</span> <span class="pre">NULL</span></code> and <code class="sql docutils literal notranslate"><span class="pre">IS</span> <span class="pre">NOT</span> <span class="pre">NULL</span></code> are unary operators
<p>This is probably caused by the fact that <code class="sql docutils literal notranslate"><span class="pre">IS</span></code> is not a binary predicate in
PostgreSQL; rather, <code class="sql docutils literal notranslate"><span class="pre">IS</span> <span class="pre">NULL</span></code> and <code class="sql docutils literal notranslate"><span class="pre">IS</span> <span class="pre">NOT</span> <span class="pre">NULL</span></code> are unary predicates
and you cannot use <code class="sql docutils literal notranslate"><span class="pre">IS</span></code> with anything else on the right hand side.
Testing in psql:</p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>=# SELECT 10 IS 10;
ERROR: syntax error at or near &quot;10&quot;
LINE 1: select 10 is 10;
LINE 1: SELECT 10 IS 10;
^
</pre></div>
</div>
<p>What you can do instead is to use the <a class="reference external" href="https://www.postgresql.org/docs/current/functions-comparison.html">IS DISTINCT FROM operator</a>, which
will gladly accept a placeholder:</p>
<p>What you can do is to use <a class="reference external" href="https://www.postgresql.org/docs/current/functions-comparison.html">IS [NOT] DISTINCT FROM</a> predicate instead:
<code class="sql docutils literal notranslate"><span class="pre">IS</span> <span class="pre">NOT</span> <span class="pre">DISTINCT</span> <span class="pre">FROM</span> <span class="pre">%s</span></code> can be used in place of <code class="sql docutils literal notranslate"><span class="pre">IS</span> <span class="pre">%s</span></code> (please
pay attention to the awkwardly reversed <code class="sql docutils literal notranslate"><span class="pre">NOT</span></code>):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">conn</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s2">&quot;SELECT * FROM foo WHERE field IS NOT DISTINCT FROM </span><span class="si">%s</span><span class="s2">&quot;</span><span class="p">,</span> <span class="p">[</span><span class="kc">None</span><span class="p">])</span>
</pre></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion psycopg3/docs/searchindex.js

Large diffs are not rendered by default.

0 comments on commit e7b2f80

Please sign in to comment.