On 04/08/2015 10:44 PM, Dagfinn Ilmari Mannsåker wrote:
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.

It's not even "in the front". It is specifically "in front of the FROM bind stack". There is a separate SELECT bind stack (for 'select' => \['foo + ?', 42]) and even a pre-SELECT bind stack (for things like https://metacpan.org/pod/DBIx::Class::SQLMaker::LimitDialects#SkipFirst)



_______________________________________________
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