Files
has_aux_table/backlog/tasks/task-18 - Fix-query-extensions-and-test-failures.md
2025-07-14 17:32:58 +00:00

1.8 KiB

id, title, status, assignee, created_date, updated_date, labels, dependencies
id title status assignee created_date updated_date labels dependencies
task-18 Fix query extensions and test failures Done
2025-07-13 2025-07-13

Description

Fix failing tests related to chained where clauses, nil value queries, and non-existent column error handling in the auxiliary table query extensions

Acceptance Criteria

  • Chained where clauses work correctly
  • Nil value queries return expected results
  • Non-existent column queries raise proper errors
  • All tests pass
  • Sorbet typechecker passes

Implementation Plan

  1. Analyze failing tests to understand root causes\n2. Fix chained where clauses by extending ActiveRecord::Relation objects\n3. Fix nil value queries by using LEFT JOIN instead of INNER JOIN\n4. Fix non-existent column error handling by forcing query execution\n5. Run full test suite to ensure no regressions\n6. Run Sorbet typechecker to ensure type safety

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\nResults: 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\nFiles modified: lib/has_aux_table.rb (setup_query_extensions method)