ActiveRecord::AuxTable -> HasAuxTable
This commit is contained in:
@@ -23,7 +23,7 @@ The gem works by:
|
||||
|
||||
```ruby
|
||||
class Vehicle < ActiveRecord::Base
|
||||
include ActiveRecord::AuxTable
|
||||
include HasAuxTable
|
||||
end
|
||||
|
||||
class Car < Vehicle
|
||||
|
||||
@@ -22,7 +22,7 @@ Create the basic module structure and entry point for the AuxTable functionality
|
||||
|
||||
## Implementation Plan
|
||||
|
||||
1. Review current lib/active_record/aux_table.rb structure\n2. Define the main AuxTable module with proper namespacing\n3. Add ActiveSupport::Concern for module inclusion\n4. Create placeholder class methods for future aux_table DSL\n5. Ensure proper autoloading and require structure
|
||||
1. Review current lib/has_aux_table.rb structure\n2. Define the main AuxTable module with proper namespacing\n3. Add ActiveSupport::Concern for module inclusion\n4. Create placeholder class methods for future aux_table DSL\n5. Ensure proper autoloading and require structure
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
|
||||
@@ -27,4 +27,4 @@ Fix failing tests related to chained where clauses, nil value queries, and non-e
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
Successfully fixed all three failing tests by:\n\n1. **Chained where clauses**: Extended ActiveRecord::Relation objects with auxiliary table support using dynamic modules, allowing unlimited chaining of where clauses with auxiliary columns\n\n2. **Nil value queries**: Changed from joins (INNER JOIN) to left_joins (LEFT JOIN) to properly handle cases where auxiliary records might not exist\n\n3. **Non-existent column error handling**: Added .load to force query execution when invalid columns are encountered, ensuring ActiveRecord::StatementInvalid is properly raised\n\n**Results**: All 47 tests now pass, Sorbet typechecker passes with no errors. The implementation maintains backward compatibility while adding robust support for complex query scenarios.\n\n**Files modified**: lib/active_record/aux_table.rb (setup_query_extensions method)
|
||||
Successfully fixed all three failing tests by:\n\n1. **Chained where clauses**: Extended ActiveRecord::Relation objects with auxiliary table support using dynamic modules, allowing unlimited chaining of where clauses with auxiliary columns\n\n2. **Nil value queries**: Changed from joins (INNER JOIN) to left_joins (LEFT JOIN) to properly handle cases where auxiliary records might not exist\n\n3. **Non-existent column error handling**: Added .load to force query execution when invalid columns are encountered, ensuring ActiveRecord::StatementInvalid is properly raised\n\n**Results**: All 47 tests now pass, Sorbet typechecker passes with no errors. The implementation maintains backward compatibility while adding robust support for complex query scenarios.\n\n**Files modified**: lib/has_aux_table.rb (setup_query_extensions method)
|
||||
|
||||
@@ -11,7 +11,7 @@ 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.
|
||||
The lib/has_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
|
||||
|
||||
@@ -24,7 +24,7 @@ The lib/active_record/aux_table.rb file is becoming too large (537 lines). The s
|
||||
- [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
|
||||
1. Create new file lib/has_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
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ The has_one association was already implemented in the generate_aux_model_class
|
||||
- Follows consistent naming convention using table_name.to_s.singularize.to_sym
|
||||
- Supports lazy loading as standard ActiveRecord has_one associations do
|
||||
|
||||
The association is set up in lines 158-162 of lib/active_record/aux_table.rb:
|
||||
The association is set up in lines 158-162 of lib/has_aux_table.rb:
|
||||
```ruby
|
||||
T.unsafe(self).has_one(
|
||||
table_name.to_s.singularize.to_sym,
|
||||
|
||||
Reference in New Issue
Block a user