Skip to content

Commit

Permalink
fix: fixes query builder order by issue in postgres (backport #32441) (
Browse files Browse the repository at this point in the history
…#32465)

fix: fixes query builder order by issue in postgres (#32441)

* fix: fixes query builder order by issue in postgres

* fix: linter

(cherry picked from commit 69efd2e)

Co-authored-by: Shridhar Patil <shridhar.p@zerodha.com>
  • Loading branch information
mergify[bot] and shridarpatil committed Oct 3, 2022
1 parent 2a82f16 commit 8851826
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions erpnext/accounts/doctype/bank_clearance/bank_clearance.py
Expand Up @@ -99,7 +99,7 @@ def get_payment_entries(self):
.where(loan_disbursement.clearance_date.isnull())
.where(loan_disbursement.disbursement_account.isin([self.bank_account, self.account]))
.orderby(loan_disbursement.disbursement_date)
.orderby(loan_disbursement.name, frappe.qb.desc)
.orderby(loan_disbursement.name, order=frappe.qb.desc)
).run(as_dict=1)

loan_repayment = frappe.qb.DocType("Loan Repayment")
Expand All @@ -126,7 +126,9 @@ def get_payment_entries(self):
if frappe.db.has_column("Loan Repayment", "repay_from_salary"):
query = query.where((loan_repayment.repay_from_salary == 0))

query = query.orderby(loan_repayment.posting_date).orderby(loan_repayment.name, frappe.qb.desc)
query = query.orderby(loan_repayment.posting_date).orderby(
loan_repayment.name, order=frappe.qb.desc
)

loan_repayments = query.run(as_dict=True)

Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/utils.py
Expand Up @@ -86,7 +86,7 @@ def get_fiscal_years(
)
)

query = query.orderby(FY.year_start_date, Order.desc)
query = query.orderby(FY.year_start_date, order=Order.desc)
fiscal_years = query.run(as_dict=True)

frappe.cache().hset("fiscal_years", company, fiscal_years)
Expand Down

0 comments on commit 8851826

Please sign in to comment.