[Dbix-class] binding variables to CASE WHEN

Augustus Saunders asaunders at solfo.com
Tue Apr 7 18:28:30 GMT 2015

On Apr 7, 2015, at 11:00 AM, Dagfinn Ilmari Mannsåker <ilmari at ilmari.org> wrote:

> Augustus Saunders <asaunders at solfo.com> writes:
>> You can use literal SQL with bound parameters in most places. It's a
>> reference to an array ref: \[SQL, bind1, bind2,...].
> This shold work everywhere, and definitely works in select => [...].

Alas it does not work with key names, since they must be strings. If you need to bind parameters on the left hand side of the operator, you have to use ? or do the quoting manually.

>> You can also put ? into your sql and pass a bind array explicitly in
>> the attributes. It may take some experimentation to figure out what
>> works, as there are bugs in the bind parameter handling.
> Which bugs, specifically? Have you reported them?

Sorry, we haven't reported them yet. We're trying to prepare a patch for some other bugs, and I'm not sure if this was going to be covered or not. We are planning to fix the aliasing problems with count, but I'm not sure if we're fixing the bind problems with count. We also had bind problems with HAVING (separate from the counting bugs) but we're not sure if the problem is really with HAVING or mixing \[] and ?; it can't figure out what order to pass the bind parameters to DBI. At any rate, in our experience when you start doing more complicated things like the OP is doing, a little trial and error is required, and ultimately we had to manually quote some things.


More information about the DBIx-Class mailing list