From: Matteo Beccati <php@beccati.com>
To: Steve Atkins <steve@blighty.com>
To: PG mailing List <pgsql-general@lists.postgresql.org>
Subject: Re: Research on ?? operators
Date: Tue, 4 Jun 2019 13:01:49 +0200
Message-ID: <9e74ec66-8fbf-a2b1-dbde-c6808ded6a94@beccati.com> (raw)
In-Reply-To: <D5829AF7-2F39-44E2-81C0-D2AE19BD7D02@blighty.com>
References: <4b588eb1-a3af-3e25-c1f1-16fb93e602e3@beccati.com>
<D5829AF7-2F39-44E2-81C0-D2AE19BD7D02@blighty.com>
Hi Steve,
On 04/06/2019 12:49, Steve Atkins wrote:
> Doubling "?" to "??" isn't an obvious, intuitive way to do that, at least
> to me. Maybe it would be to people coming from Java.
Funny enough, when I proposed \? on the pg mailing lists a few years ago
I was suggested ?? to match SQL escaping and Hibernate (going from memory).
> Perl's DBD::Pg deals with it in two ways. One is to allow escaping
> the ? with a backslash - so "?" is a placeholder, while "\?" is passed as
> "?" to the database. That's more consistent with other languages, and
> I think you're far less likely to ever see a backslash in a custom operator
> than "??".
That is true as well, but '\' being also the escape character for
strings would also lead to some WTF moments if one tried to escape the
backslash itself, e.g. '\\? === '\?'.
> The other is that it supports the postgresql standard placeholders - $1,
> $2 etc. - which avoid the issue and are more flexible. It also has a configuration
> option to completely ignore "?" in queries, so "$1" is a placeholder and "?"
> is passed through to the database.
>
> (Though I like the ":foo" or "@foo" style named placeholders best)
PDO does support both positional "?" and ":foo" named placeholders.
Adding an option to disable one would probably break much more code and
libraries than just a simple escape character.
Cheers
--
Matteo Beccati
Development & Consulting - http://www.beccati.com/
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: php@beccati.com, steve@blighty.com
Subject: Re: Research on ?? operators
In-Reply-To: <9e74ec66-8fbf-a2b1-dbde-c6808ded6a94@beccati.com>
References: <4b588eb1-a3af-3e25-c1f1-16fb93e602e3@beccati.com> <D5829AF7-2F39-44E2-81C0-D2AE19BD7D02@blighty.com> <9e74ec66-8fbf-a2b1-dbde-c6808ded6a94@beccati.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox