Augustus Saunders <asaund...@solfo.com> writes:

> Outside of count, here is an example that messes up:
>
>     'attrs' => {
>       'select' => [
>                     \[
>                         'aggfunction(col, ?)',
>                         'somevar'
>                       ]
>                   ],
>       'group_by' => 'somecolumn1',
>       'having' => {
>         '-and' => [
>                     {
>                       'aggfunction(col, ?)' => {'>' => '0'}
>                     }
>                   ]
>       }
>       'bind' => [
>                   'somevar'
>                 ],
>     },
>     'where' => {
>       '-and' => [
>                   {
>                     'somecolumn2' => 1
>                   }
>                 ]
>     }
>
> The 'somevar' that comes from bind => ['somevar'] is not being
> correctly lined up with the unbound ? from the having clause. At the
> DBI level we bind_param(1,somevar), bind_param(2, somevar),
> bind_param(3, 1), bind_param(4, 0), but the order should go somevar,
> 1, somevar, 0.

Well, DBIC can't possibly know which part the bind parameter goes with,
so as Peter explained it just sticks it at the front.  Also, having an
expression on the LHS of the hash will break if you enable quote_names.
Instead, just do:

    having => \['aggfunction(col, ?) > ?', 'somevar', 0],

and it'll go in the right place reliably.

-- 
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
 the consequences of."                              -- Skud's Meta-Law


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to