public inbox for [email protected]  
help / color / mirror / Atom feed
From: Paolo De Stefani <[email protected]>
To: Christophe Pettus <[email protected]>
Cc: Psycopg <[email protected]>
Subject: Re: Query with boolean parameter
Date: Sat, 19 Mar 2022 13:10:54 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>

Il 19/03/2022 01:00 Christophe Pettus ha scritto:
>> On Mar 18, 2022, at 16:56, Paolo De Stefani <[email protected]> 
>> wrote:
>> Is there any reason why the second query results in a syntax error?
> 
> There's not IS operator in PostgreSQL (or in SQL).  IS NULL, IS NOT
> NULL, IS TRUE, and IS FALSE are in effect unary postfix operators, so
> you can't construct them that way via parameter substitution.

Thanks, i see

The problem is (for me) that with psycopg2 this works:
cur.execute('SELECT * FROM system.app_user WHERE can_edit_views IS 
TRUE')
cur.execute('SELECT * FROM system.app_user WHERE can_edit_views IS %s', 
(True,))
cur.execute('SELECT * FROM system.app_user WHERE can_edit_views IS %s', 
(None,))

Switching to psycopg 3 i have to consider many more differences than i 
expected

-- 
Paolo De Stefani





view thread (7+ messages)  latest in thread

reply

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Query with boolean parameter
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox