[Dbix-class] Numbered placeholders and DBIC
rabbit+dbic at rabbit.us
Sat Dec 20 16:02:31 GMT 2014
On 12/19/2014 11:40 AM, Tim Bunce wrote:
> For code using DBIx::Class the problem is more tricky. I'm pretty sure
> that SQL::Abstract and thus DBIx::Class only support question mark
> placeholders. That means it probably impossible to use expressions
> containing a question mark operator with SQL::Abstract/DBIx::Class.
> (Though I'd be delighted to be proven wrong.)
On 12/17/2014 05:19 AM, Darren Duncan wrote:
> This being said, I don't know if DBIx::Class is compatible with that way of using PostgreSQL, not that this can't change.
Actually DBIC/SQLA likely will not be able to support numbered
placeholders for a very long time if ever at all.
The issue stems from the reliance of SQLA/DBIC on "composable SQL
snippets", that is the output of intermediate renderers is "some sql
with the bind values to go with it". Such expressions are inherently
unorderable (how do you know where a particular subquery is going to be
used, before/after what other bind variables?)
There is likely a way to do a parse at the *final* assembly and replace
every ? with a numbered placeholder but it will be 1) fragile, 2) only
done for the sake of few engines.
As such I see it as a very low priority bordering on an anti-feature,
especially given that the overhead of nonexistent bind-value-reuse is
exceedingly small in practice.
Of course I could be quite misguided in my cost/benefit analyzis - feel
free to tell me where I am wrong.
More information about the DBIx-Class