mirror of
https://github.com/we-promise/sure
synced 2026-04-25 17:15:07 +02:00
Fix transactions page crash when no accounts exist (#1453)
Skip the accessible_account_ids filter when the array is empty, preventing Rails from creating a "none" relation that causes .take to return nil. An empty [] is truthy in Ruby, so `if accessible_account_ids` was applying a WHERE account_id IN () clause that matched nothing. Fixes #1452 Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Juan José Mata
parent
6d2d340cf3
commit
23f70976f6
@@ -28,6 +28,9 @@ class Transaction::Search
|
||||
# This already joins entries + accounts. To avoid expensive double-joins, don't join them again (causes full table scan)
|
||||
query = family.transactions.merge(Entry.excluding_split_parents)
|
||||
|
||||
# Scope to accessible accounts when provided
|
||||
query = query.where(entries: { account_id: accessible_account_ids }) if accessible_account_ids&.any?
|
||||
|
||||
query = apply_active_accounts_filter(query, active_accounts_only)
|
||||
query = apply_category_filter(query, categories)
|
||||
query = apply_type_filter(query, types)
|
||||
|
||||
Reference in New Issue
Block a user