Subject: | Resultset 'having' documentation error |
Date: | Tue, 21 Dec 2010 17:56:24 -0600 |
To: | bug-DBIx-Class [...] rt.cpan.org |
From: | Wes Malone <wesdmalone [...] gmail.com> |
According to the Resultset docs in 0.08124, 'having' is used in a
search like this:
having => { 'count(employee)' => { '>=', 100 } }
This generates incorrect SQL. My code looks like this:
Dwarn $schema->resultset('Invoice')
->search({},{
select => ['me.id'],
join => 'disbursements',
having => { 'sum(disbursements.amount_recieved)' => { '=', 0 } }
})->next;
and the SQL it generates and the corresponding error message:
SELECT [me].[id]
FROM [Invoices] [me]
LEFT JOIN [AccountsReceivableDisbursement] [disbursements]
ON [disbursements].[invoice_id] = [me].[id]
HAVING [sum( disbursements].[amount_recieved ) ] = ?/'0'
DBIx::Class::ResultSet::next(): DBI Exception: DBD::ODBC::st execute
failed: [Microsoft][SQL Server Native Client 10.0][SQL Server]The
multi-part identifier "sum(disbursements.amount_recieved)" could not
be bound. (SQL-42000)
[Microsoft][SQL Server Native Client 10.0][SQL Server]Statement(s)
could not be prepared.
(SQL-42000) [for Statement "SELECT [me].[id] FROM [Invoices] [me] LEFT
JOIN [AccountsReceivableDisbursement] [disbursements] ON
[disbursements].[invoice_id] = [me].[id] HAVING
[sum(disbursements].[amount_recieved)] = ?" with ParamValues: 1='0.']
at script\workbench.pl line 17
Environment:
Perl 5.10.1, MSWin32-x86-multi-thread
Windows 7, x64
DBIx::Class 0.08124
Thanks.