Subject: | [PATCH] SQL::Abstract: ORDER BY clause with with placeholders and bind values |
Date: | Tue, 31 Mar 2015 10:07:25 +0200 |
To: | <bug-SQL-Abstract [...] rt.cpan.org> |
From: | fabrizio.ge [...] tiscali.it |
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,@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).
Using Perl v5.14.2
and SQL::Abstract 1.72, but the patch also applies to the latest
Git.
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/
Message body is not shown because sender requested not to inline it.