Conversation
Pull Request Test Coverage Report for Build 21799330042Details
💛 - Coveralls |
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.
Fixed bug where Model had 2 m2m fields to same model, so that filtering by both at the same time was improssible due to alias issues
Repacked version #1972
Fixes issue #1969
AI Summary:
This pull request improves support for filtering across multiple many-to-many (M2M) relationships to the same target table in the ORM. It ensures that queries involving multiple M2M relations from a single model to the same target produce correct and distinct SQL JOINs by introducing proper aliasing. The changes are validated with new tests and model definitions.
Query building and aliasing improvements:
get_joins_for_related_fieldandresolve_nested_fieldintortoise/query_utils.pyto ensure that when filtering or joining on multiple M2M relations to the same target table, the generated SQL uses distinct aliases for each join, preventing conflicts and ensuring correct query results. [1] [2] [3]Testing for M2M filtering and SQL generation:
FlavorandDrinktotests/testmodels.py, withDrinkhaving two separate M2M relations toFlavorviaflavorsandtoppings.test_m2m_filter_multiple_relations_to_same_tableintests/test_filtering.pyto verify that filtering on both M2M relations returns the correct results.test_m2m_filter_two_relations_same_target_produces_aliased_joinsintests/test_sql.pyto assert that the generated SQL contains the expected aliased JOINs for both MySQL and Postgres/SQLite dialects.Test imports and setup:
tests/test_filtering.pyandtests/test_sql.pyto include the newDrinkandFlavormodels. [1] [2]