Re: Query with boolean parameter

From: Paolo De Stefani <paolo(at)paolodestefani(dot)it>
To: Christophe Pettus <xof(at)thebuild(dot)com>
Cc: Psycopg <psycopg(at)postgresql(dot)org>
Subject: Re: Query with boolean parameter
Date: 2022-03-19 12:10:54
Message-ID: d88ac5f2ae2457bb2b97f98c47cfcdfc@paolodestefani.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

Il 19/03/2022 01:00 Christophe Pettus ha scritto:
>> On Mar 18, 2022, at 16:56, Paolo De Stefani <paolo(at)paolodestefani(dot)it>
>> 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

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Daniele Varrazzo 2022-03-19 13:43:19 Re: Query with boolean parameter
Previous Message Christophe Pettus 2022-03-19 00:00:20 Re: Query with boolean parameter