Commit Graph

26 Commits

Author SHA1 Message Date
Dylan Knutson
19d96dfebe update tapioca, more type annotations 2025-07-16 16:24:35 +00:00
Dylan Knutson
fda95fb33f more rspec 2025-07-15 07:22:38 +00:00
Dylan Knutson
239afcbadb fix specs, use relation hooks 2025-07-15 06:21:10 +00:00
Dylan Knutson
fd91328334 more wip before breaking everything 2025-07-15 04:11:54 +00:00
Dylan Knutson
5f358abae6 checkpoint before breaking things 2025-07-15 03:50:34 +00:00
Dylan Knutson
9f73c0d364 ActiveRecord::AuxTable -> HasAuxTable 2025-07-14 17:32:58 +00:00
Dylan Knutson
81ec3d2902 use migration helpers in spec 2025-07-14 17:13:58 +00:00
Dylan Knutson
c870eef9bc migration extension helpers 2025-07-14 17:08:22 +00:00
Dylan Knutson
4933e63f31 fix model saving 2025-07-14 07:36:50 +00:00
Dylan Knutson
30b017906f more ar hacking 2025-07-14 05:44:01 +00:00
Dylan Knutson
bb5c22b070 lefthook ignore vscode dir 2025-07-14 05:41:49 +00:00
Dylan Knutson
a09465ac54 Replace includes with eager_load for optimal single-query performance
- 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
2025-07-13 06:23:07 +00:00
Dylan Knutson
4f41b66f85 Improve query performance with includes and add comprehensive performance tests
- 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
2025-07-13 06:17:00 +00:00
Dylan Knutson
fc6fd71e60 feat: Completely rewrite query extensions for simplicity and maintainability
- 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
2025-07-13 06:03:03 +00:00
Dylan Knutson
f8b9b847e5 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
2025-07-13 05:02:20 +00:00
Dylan Knutson
cde0896e98 Fix query extensions and test failures
- 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
2025-07-13 04:48:46 +00:00
Dylan Knutson
4e576d2a59 aux attribute 2025-07-13 04:13:39 +00:00
Dylan Knutson
e1c1e03e74 api without block syntax 2025-07-13 03:36:29 +00:00
Dylan Knutson
af97998393 integration tests 2025-07-13 03:22:23 +00:00
Dylan Knutson
a9d315d993 feat: implement auxiliary model class generator (Task 3)
- Add generate_aux_model_class method to dynamically create ActiveRecord models
- Generated models extend ActiveRecord::Base with proper table name configuration
- Add belongs_to association back to STI parent class with correct foreign key
- Add model_class attribute to Configuration class for storing generated model reference
- Integrate model generation into aux_table DSL method
- Add fallback simple class for test environments without full ActiveRecord
- Add comprehensive test suite covering model generation functionality
- Support proper constant creation and conflict detection
- All 33 tests passing with appropriate skipping for test environment

This completes Task 3: auxiliary model classes are now dynamically generated
when aux_table is called, providing the foundation for ActiveRecord associations.
2025-07-13 02:25:19 +00:00
Dylan Knutson
8351d756c0 srb strict typing 2025-07-13 02:19:55 +00:00
Dylan Knutson
c38482c9d8 feat: add comprehensive Sorbet type annotations with ActiveSupport::Concern support
- Add sorbet-runtime dependency to gemspec
- Add comprehensive type annotations to Configuration class
- Create RBI file with mixes_in_class_methods for proper class method typing
- Add ActiveSupport::Concern shim to handle included and class_methods DSL
- Add parameter validation for edge cases when RBI bypasses runtime checks
- Update tests to expect correct error messages from manual validation
- All 26 tests passing with full type safety
- Sorbet type checker passes with no errors

This implements the ActiveSupport::Concern DSL generator approach from
https://github.com/Shopify/tapioca/pull/360 to properly handle Sorbet
type checking with ActiveSupport::Concern modules.
2025-07-13 02:12:56 +00:00
Dylan Knutson
164f16b048 fix: use POSIX-compliant shell syntax in json-lint hook 2025-07-13 02:02:26 +00:00
Dylan Knutson
51e7f9545b pre-commit checking of json,yaml,rb files 2025-07-13 01:37:31 +00:00
Dylan Knutson
6fc3f772c3 Set up lefthook for Ruby formatters and type checking 2025-07-13 01:22:54 +00:00
Dylan Knutson
fd82eafb50 inital commit 2025-07-12 09:41:45 -07:00