Fix SQLAlchemy auto-correlation bug in vestigingen reader + add reader tests#21
Merged
Fix SQLAlchemy auto-correlation bug in vestigingen reader + add reader tests#21
Conversation
…ader tests The exists() subquery in get_outdated_vestigingen referenced VestigingenORM, which also appears in the outer query JOIN. SQLAlchemy auto-correlated the subquery by removing VestigingenORM from its FROM clause, causing a runtime error. Fixed by adding .correlate(BasisProfielORM) to explicitly scope correlation to only BasisProfielORM. Added integration tests for KvKVestigingenReader and VestigingsProfielReader that execute queries against SQLite, which would have caught this bug before merge. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_outdated_vestigingen_count()andget_outdated_vestigingen(): theexists()subquery referencedVestigingenORM, which also appears in the outer query JOIN — SQLAlchemy auto-correlated it by droppingVestigingenORMfrom the subquery's FROM clause. Fixed with.correlate(BasisProfielORM).tests/db/test_kvkvestigingen_reader.py(18 tests) andtests/db/test_vestigingsprofiel_reader.py(21 tests) — integration tests that execute queries against SQLite, which would have caught this bug before merge.Root cause
No database migration needed
No schema changes — only query logic and new tests.
Test plan
just check-allpasses (run twice)🤖 Generated with Claude Code