- Replace all includes() with eager_load() in find, find_by, and where methods
- eager_load forces single LEFT OUTER JOIN queries instead of potential N+1 queries
- Update test expectations to validate single query performance
- All query methods now use optimized single queries:
* Car.find(id) - 1 query with full JOIN
* Car.find_by(fuel_type: 'hybrid') - 1 query with full JOIN
* Car.where(fuel_type: 'hybrid') - 1 query with full JOIN
* Chained where() queries - 1 query with full JOIN
Performance improvements:
- Eliminated N+1 queries for find and find_by methods
- Consistent single-query behavior across all query methods
- Proper association loading with eager_load vs includes
- All 58 tests passing with optimal performance
- Replace left_joins with includes in auto-join queries for better performance
- Remove complex after_initialize callback since includes handles association loading
- Add automatic includes to find method for consistent behavior
- Add comprehensive performance tests with query counting
- Fix Sorbet type checking by adding ActiveSupport::Notifications to todo.rbi
Performance improvements:
- where() queries now use single query with includes
- N+1 queries avoided for multiple record loading
- All query methods (find, find_by, where) now optimized
- Researched how established Rails gems (Paranoia, Kaminari) handle AR extensions
- Eliminated Thread.current hacks, complex recursion prevention, and method aliasing
- Implemented clean prepend patterns with proper delegation to super()
- Automatic behavior maintained since users explicitly opt-in with aux_table
- All query methods work seamlessly: find, find_by, where, chained where
- Proper error handling for unknown columns
- All 47 tests pass including 19 query extension tests
- No Sorbet type errors
- Code is now readable, maintainable, and follows Rails conventions
Breaking changes: None - all existing functionality preserved
Performance: Improved due to simpler, more direct implementation
- 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
- Fix chained where clauses by extending ActiveRecord::Relation objects with auxiliary table support
- Fix nil value queries by using LEFT JOIN instead of INNER JOIN
- Fix non-existent column error handling by forcing query execution
- All 47 tests now pass, no regressions
- Sorbet typechecker passes with no errors
- Update backlog tasks to reflect completed work