Extract query extensions into separate module and fix infinite recursion
- Extract setup_query_extensions and related methods to new QueryExtensions module - Reduce main aux_table.rb file from 537 to 335 lines (202 lines removed) - Create lib/active_record/aux_table/query_extensions.rb with RelationMethods - Fix infinite recursion bug by using super() calls and disabling aux processing on joined relations - All 47 tests pass and no Sorbet type errors - Improve code organization and maintainability - Complete task-19 with all acceptance criteria met Closes: task-19
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
---
|
||||
id: task-19
|
||||
title: Extract query extensions into separate module
|
||||
status: Done
|
||||
assignee: []
|
||||
created_date: '2025-07-13'
|
||||
updated_date: '2025-07-13'
|
||||
labels: []
|
||||
dependencies: []
|
||||
---
|
||||
|
||||
## Description
|
||||
|
||||
The lib/active_record/aux_table.rb file is becoming too large (537 lines). The setup_query_extensions method contains complex logic for handling where clauses, joins, and relation extensions that should be extracted into a dedicated module for better code organization and maintainability.
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- [x] Create new ActiveRecord::AuxTable::QueryExtensions module
|
||||
- [x] Move setup_query_extensions method to new module
|
||||
- [x] Move all query-related helper methods to new module
|
||||
- [x] Maintain all existing functionality
|
||||
- [x] All tests continue to pass
|
||||
- [x] File structure is cleaner and more maintainable
|
||||
- [x] Code is properly documented with type signatures
|
||||
## Implementation Plan
|
||||
|
||||
1. Create new file lib/active_record/aux_table/query_extensions.rb\n2. Define ActiveRecord::AuxTable::QueryExtensions module\n3. Move setup_query_extensions method to QueryExtensions module\n4. Move helper methods (contains_aux_columns?, aux_column_names, extend_relation_with_aux_table_support) to QueryExtensions\n5. Update main aux_table.rb to include QueryExtensions module\n6. Ensure all Sorbet type signatures are properly maintained\n7. Run tests to verify no regressions\n8. Run Sorbet typechecker to ensure type safety\n9. Update require statements and module structure as needed
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
Successfully extracted query extensions into separate module. The main aux_table.rb file has been reduced from 537 lines to 335 lines (202 lines removed). Created new QueryExtensions module with RelationMethods that get prepended to ActiveRecord::Relation. The approach changed from dynamically creating modules per class to a single module that checks if queried class has aux tables. All functionality is maintained and file structure is cleaner and more maintainable. Some Sorbet type issues remain but core functionality works correctly.
|
||||
|
||||
Successfully extracted query extensions into separate module and fixed infinite recursion bug. The main aux_table.rb file has been reduced from 537 lines to 335 lines (202 lines removed). Created new QueryExtensions module with RelationMethods that get prepended to ActiveRecord::Relation. Fixed infinite recursion issue by using super() calls and temporarily disabling aux table processing on joined relations. All 47 tests pass and no Sorbet type errors. The approach changed from dynamically creating modules per class to a single module that checks if queried class has aux tables. All functionality is maintained and file structure is cleaner and more maintainable.
|
||||
Reference in New Issue
Block a user