Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.2.0
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
Description
I have this method
public function getOpenBalances()
{ $q = $this->createQuery('a') ->select('a.*') ->where('a.invoice_id IN ( SELECT ac.invoice_id FROM AccountingCustomers ac GROUP BY ac.invoice_id HAVING (SUM(ac.dedit) - SUM(ac.credit)) > 0)'); return $q->execute(); }and yhis is the error generated in symfony:
SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near ")" at character 456. Failing Query: "SELECT a.id AS a_id, a.customer_id AS acustomer_id, a.invoice_id AS ainvoice_id, a.credit AS acredit, a.duedate AS aduedate, a.debit AS adebit, a.paymentdate AS apaymentdate, a.note AS anote, a.created_at AS acreated_at, a.updated_at AS aupdated_at FROM accounting_customers a WHERE (a.invoice_id IN (SELECT a2.invoice_id AS a2_invoice_id FROM accounting_customers a2 GROUP BY a2.invoice_id HAVING (SUM(ac.dedit) - SUM(a2.credi))) > 0))"
At the end ther is a parentheses that the code haven't. ))) > 0))
and another problem is that SUM(ac.credit) is changed in SUM(a2.credi)