mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-19 19:37:56 +00:00
fix(postgres): satisfy strict GROUP BY in Stock And Account Value Comparison report
Wrap the non-aggregated, functionally-dependent column(s) in Max()/Min() (or add them to GROUP BY) so the report's grouped query is valid under PostgreSQL's strict GROUP BY. No behaviour change on MariaDB. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -86,12 +86,14 @@ def get_stock_ledger_data(report_filters, filters):
|
|||||||
"Stock Ledger Entry",
|
"Stock Ledger Entry",
|
||||||
filters=filters,
|
filters=filters,
|
||||||
fields=[
|
fields=[
|
||||||
"name",
|
# name is arbitrary per grouped voucher (many SLEs); posting_date/posting_time are constant
|
||||||
|
# per voucher -> MAX() keeps the GROUP BY valid on postgres with the same values MySQL picked.
|
||||||
|
{"MAX": "name", "as": "name"},
|
||||||
"voucher_type",
|
"voucher_type",
|
||||||
"voucher_no",
|
"voucher_no",
|
||||||
{"SUM": "stock_value_difference", "as": "stock_value"},
|
{"SUM": "stock_value_difference", "as": "stock_value"},
|
||||||
"posting_date",
|
{"MAX": "posting_date", "as": "posting_date"},
|
||||||
"posting_time",
|
{"MAX": "posting_time", "as": "posting_time"},
|
||||||
],
|
],
|
||||||
group_by="voucher_type, voucher_no",
|
group_by="voucher_type, voucher_no",
|
||||||
order_by="posting_date ASC, posting_time ASC",
|
order_by="posting_date ASC, posting_time ASC",
|
||||||
@@ -113,10 +115,12 @@ def get_gl_data(report_filters, filters):
|
|||||||
"GL Entry",
|
"GL Entry",
|
||||||
filters=filters,
|
filters=filters,
|
||||||
fields=[
|
fields=[
|
||||||
"name",
|
# name is arbitrary per grouped voucher (many GL entries); posting_date is constant per
|
||||||
|
# voucher -> MAX() keeps the GROUP BY valid on postgres with the same values MySQL picked.
|
||||||
|
{"MAX": "name", "as": "name"},
|
||||||
"voucher_type",
|
"voucher_type",
|
||||||
"voucher_no",
|
"voucher_no",
|
||||||
"posting_date",
|
{"MAX": "posting_date", "as": "posting_date"},
|
||||||
{
|
{
|
||||||
"SUB": [{"SUM": "debit_in_account_currency"}, {"SUM": "credit_in_account_currency"}],
|
"SUB": [{"SUM": "debit_in_account_currency"}, {"SUM": "credit_in_account_currency"}],
|
||||||
"as": "account_value",
|
"as": "account_value",
|
||||||
|
|||||||
Reference in New Issue
Block a user