Incorrect results due to placeholders in HAVING clauses

1 view
Skip to first unread message

Diab Jerius

unread,
Aug 24, 2015, 11:45:23 AM8/24/15
to dbix-datamodel
I'm getting incorrect results when using the -having => \%conditions
syntax, apparently due to using placeholders in the generated HAVING
clause.

I'm using DBD::SQLite 1.39.

I've attached test code.

Here's the output:

% perl tst.pl
$VAR1 = [];

$VAR1 = [
bless( {
'count(*)' => 1
}, 'Bar::Foo' )
];

The second $VAR1 value is the correct one, and corresponds to
submitting the condition as a string.

The generated SQL which produces the incorrect result uses a
placeholder, but is otherwise identical to the other.

Are bound parameters in HAVING not universally supported? A long time
Sybase user I asked did not believe that one could use placeholders in
HAVING clauses.

Thanks,
Diab
tst.pl

Dami Laurent (PJ)

unread,
Aug 25, 2015, 1:36:33 AM8/25/15
to dbix-da...@googlegroups.com
> Are bound parameters in HAVING not universally supported? A long time
> Sybase user I asked did not believe that one could use placeholders in
> HAVING clauses.
>

Very few things are universally supported. Behaviours vary between DBMS vendors.
I don't know the answer for this particular case; may be the sqlite mailing list could help.

Diab Jerius

unread,
Aug 25, 2015, 10:16:54 AM8/25/15
to dbix-datamodel
My understanding after reading the code is that -having is treated
identically to -where in SQL::Abstract::More. Any chance of
introducing alternate behavior there so that it's possible to use a
hash table argument to -having without generating placeholders?

Thanks,
Diab

Laurent Dami

unread,
Aug 25, 2015, 3:29:38 PM8/25/15
to dbix-da...@googlegroups.com
Le 25.08.2015 16:16, Diab Jerius a écrit :
> Any chance of introducing alternate behavior there so that it's
> possible to use a hash table argument to -having without generating
> placeholders?

SQL::Abstract::More inherits from SQL::Abstract, so the -ident syntax
for avoiding placeholders is supported :

-having => {'count(*)' => {-ident => 1}}

see https://metacpan.org/pod/SQL::Abstract#ident

Diab Jerius

unread,
Aug 25, 2015, 5:03:01 PM8/25/15
to dbix-datamodel
Thanks.
Reply all
Reply to author
Forward
0 new messages