Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nVXvN-0002Ia-5w for psycopg@arkaria.postgresql.org; Sat, 19 Mar 2022 12:11:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nVXvK-0001FS-NH for psycopg@arkaria.postgresql.org; Sat, 19 Mar 2022 12:11:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nVXvK-0001FI-14 for psycopg@lists.postgresql.org; Sat, 19 Mar 2022 12:11:10 +0000 Received: from olivedrab.birch.relay.mailchannels.net ([23.83.209.135]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nVXvC-0007rt-61 for psycopg@postgresql.org; Sat, 19 Mar 2022 12:11:09 +0000 X-Sender-Id: cp7oy65bvo|x-authuser|paolo@paolodestefani.it Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 43CE320AFB; Sat, 19 Mar 2022 12:10:58 +0000 (UTC) Received: from lu-shared04.cpanelplatform.com (unknown [127.0.0.6]) (Authenticated sender: cp7oy65bvo) by relay.mailchannels.net (Postfix) with ESMTPA id EC0EA2091A; Sat, 19 Mar 2022 12:10:56 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1647691857; a=rsa-sha256; cv=none; b=3kR7c4g5SVzMkuIEQ64jczT8ZvwI4bgjEMokknBshnAQYtQoAZ2mIMtaVkYtIQwXyH58ZI TjlBFH5/hlR5nzpeeYzyLzgmy1tR0Fw5pfQpPl03meN7VtgQFIRq2DbLFvTT2z1T0LfGEw KSljmu33O+1vxDNgDKv5WewD1lMf5VBmGDaiiR7wPGBB+GVAYY4JeHPlsCVOljNf40cqYJ 88lgLgpcmcNW8yVVlHDOAPbOw4ITN5XMsQhBB4aYDolmG4rdP1dyGusbn9POyVznYPII7v xpQsnmcQciMpHczuXH9oso8AI5+IhhjXW2vkHtTyfScxE0xO6wY6BmU2o7p//A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1647691857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=w66jXuSnbmV2NP20+nLjE8GdTTiw5DyECUKHF2iZNuU=; b=zC9db2iRjdZ1jUVSL/fXAr8tFksdnreVWnEKfmjqzD2SUlbm3n9/OOlekrBfCQL06Cwd5y /VaPxtgwdkojXP+B4a46LpBH1w+/RRt05+TAbIFC/XQ+0mwqe++cXAfVRWaj49VEIHFkCC El6vCnvylcBEywFTKobdU+zQBLXWhYjzvDa2Mr2wBYWJNYxacnak9nzpBihN+JlwHNPrFU 2G7Y9qTR94ciY0ERQpdcdW4onWLjZut8Oaon8iBeb50AfCtxb7DPKysFNh3yjvEXoa5C43 MksVR1VL4dCsAcBjKm4gtHrkYLVq2YJP+bIYXrgnZQ0+7MKsWYOhzQyKgsqESA== ARC-Authentication-Results: i=1; rspamd-74bfb75fc6-fgp5v; auth=pass smtp.auth=cp7oy65bvo smtp.mailfrom=paolo@paolodestefani.it X-Sender-Id: cp7oy65bvo|x-authuser|paolo@paolodestefani.it Received: from lu-shared04.cpanelplatform.com ([UNAVAILABLE]. [107.189.4.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.124.238.100 (trex/6.5.3); Sat, 19 Mar 2022 12:10:58 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: cp7oy65bvo|x-authuser|paolo@paolodestefani.it X-MailChannels-Auth-Id: cp7oy65bvo X-Shelf-Slimy: 0b7adf8877784238_1647691858072_1220619032 X-MC-Loop-Signature: 1647691858072:1346964355 X-MC-Ingress-Time: 1647691858072 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=paolodestefani.it; s=default; h=Content-Transfer-Encoding:Content-Type: Message-ID:References:In-Reply-To:Subject:Cc:To:From:Date:MIME-Version:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=w66jXuSnbmV2NP20+nLjE8GdTTiw5DyECUKHF2iZNuU=; b=y4ED8/K4y0a2pAszO3CVefw2Ne aswbgU0TLLYFmxQi7ciK0sCUlTbbs7ugUztyCr7R0ttJ5Su+ML9rVvPH9w2sjzpugnrT7hy8KpBVj PdmMK5lXHmuBJV2QlXV2vDe63VBDTMmakY7pdPuZ6qoHLMa9D7irP1jf5h1jsUGNDYUTh9mGMpGp3 vFTXj2JgrDwnUKS8/0CjAs5BNP5RcxsljZRu/LMM2PZtJ+G9uN1R/WprRkq+qg8lu/ZmFp57Edot6 /WIf79PpaXBqrkPLnA9sxuN5MHNlVuyuqxRDg2sZQVnsinrMS5xHbSvjJVMA+nL98tvXTLsFKP1VH CFHonVrA==; Received: from [::1] (port=52092 helo=lu-shared04.cpanelplatform.com) by lu-shared04.cpanelplatform.com with esmtpa (Exim 4.95) (envelope-from ) id 1nVXv4-00C88J-UB; Sat, 19 Mar 2022 13:10:54 +0100 MIME-Version: 1.0 Date: Sat, 19 Mar 2022 13:10:54 +0100 From: Paolo De Stefani To: Christophe Pettus Cc: Psycopg Subject: Re: Query with boolean parameter In-Reply-To: <74FC637F-2D25-4CD0-A075-9CB5293FCA5B@thebuild.com> References: <8df15d1263aaa1a9d36eacb0e5b9a28e@paolodestefani.it> <74FC637F-2D25-4CD0-A075-9CB5293FCA5B@thebuild.com> User-Agent: Roundcube Webmail/1.4.12 Message-ID: X-Sender: paolo@paolodestefani.it Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-AuthUser: paolo@paolodestefani.it List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Il 19/03/2022 01:00 Christophe Pettus ha scritto: >> On Mar 18, 2022, at 16:56, Paolo De Stefani >> 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