[Dbix-class] [PATCH] SQL::Abstract: ORDER BY clause with with placeholders and bind values

fabrizio.ge at tiscali.it fabrizio.ge at tiscali.it
Sun Jan 18 18:15:27 GMT 2015


  Hello,
I'd like to generate some SQL like:

WHERE age >= 25
ORDER BY
dept_id = ? DESC, name ASC

The intention is, for example, to have all
records with dept_id=10 on top (so the boolean expression dept_id=10 has
value 1), then the others.

I could not do it with SQL::Abstract without
patching it: the patch is attached.

This is the code

my $a =
SQL::Abstract->new;
my $id=10;
my ($b, at bind)=$a->where({age => {">=", 25
}},
 [
 { -desc => ["dept_id=?" => ($id)] },
 { -asc => 'name' }

]);
print $b . "n" . qq(@bind) . "n"

With the patch, @bind is (25, 10),
the desired result, without the patch it is (25).

Could you please
apply the patch? Or specify a different solution not involving patching
the code?

Regards,
Fabrizio
  


Connetti gratis il mondo con la nuova indoona:  hai la chat, le chiamate, le video chiamate e persino le chiamate di gruppo.
E chiami gratis anche i numeri fissi e mobili nel mondo!
Scarica subito l’app Vai su https://www.indoona.com/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20150118/ada099bc/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: abstract.patch
Type: text/x-diff
Size: 392 bytes
Desc: not available
URL: <http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20150118/ada099bc/attachment.patch>


More information about the DBIx-Class mailing list