mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-15 07:28:39 +00:00
fix(setup): deterministic tiebreaker in get_exchange_rate Currency Exchange lookup (Postgres)
get_exchange_rate orders Currency Exchange by 'date desc' LIMIT 1 with no unique tiebreaker. Currency Exchange autoname {date}-{from}-{to}-{purpose} allows multiple same-date rows (different purpose) for one currency pair; on the no-purpose-filter path all match, so MariaDB and Postgres can return a different exchange_rate for the same inputs. Add 'name desc' so both engines pick the same row. MariaDB row count unchanged.
This commit is contained in:
@@ -95,7 +95,11 @@ def get_exchange_rate(
|
||||
|
||||
# cksgb 19/09/2016: get last entry in Currency Exchange with from_currency and to_currency.
|
||||
entries = frappe.get_all(
|
||||
"Currency Exchange", fields=["exchange_rate"], filters=filters, order_by="date desc", limit=1
|
||||
"Currency Exchange",
|
||||
fields=["exchange_rate"],
|
||||
filters=filters,
|
||||
order_by="date desc, name desc",
|
||||
limit=1,
|
||||
)
|
||||
if entries:
|
||||
return flt(entries[0].exchange_rate)
|
||||
|
||||
Reference in New Issue
Block a user