-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(datastore): Switch to BFS in Join Builder for Alias, fixes - #2488 #2693
Conversation
- Replace the recursiveBuildJoins method (DFS-based) with buildJoinsUsingBFS to address issues with incorrect table alias usage in WHERE conditions. - The BFS approach ensures that all tables directly related to the root table are assigned their original names without any numeric suffixes, enhancing the readability and correctness of SQL queries, especially in WHERE clauses involving intermediate tables in multilevel joins. - Implement a tracking mechanism for visited (table, FK) combinations to support multiple foreign keys and prevent infinite loops in cyclic relationships. - Add detailed JavaDoc comments to explain the new BFS-based join building logic, its advantages in alias management, and its approach to handling complex table relationships. - This change aims to improve the reliability of SQL query construction, particularly by ensuring that WHERE conditions on intermediate tables in multilevel joins are more intuitive and less error-prone.
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #2693 +/- ##
==========================================
+ Coverage 42.85% 42.92% +0.06%
==========================================
Files 905 905
Lines 29098 29114 +16
Branches 4142 4144 +2
==========================================
+ Hits 12471 12497 +26
+ Misses 15269 15260 -9
+ Partials 1358 1357 -1 |
Changes Look great. Just as a reminder, we discussed addition of query using CPK, as well as multiple statements in where clause. |
Thanks. I have added tests for querying using CPK, as well as multiple conditions in where statement. |
...idTest/java/com/amplifyframework/datastore/storage/sqlite/SQLiteStorageAdapterQueryTest.java
Outdated
Show resolved
Hide resolved
...idTest/java/com/amplifyframework/datastore/storage/sqlite/SQLiteStorageAdapterQueryTest.java
Show resolved
Hide resolved
...idTest/java/com/amplifyframework/datastore/storage/sqlite/SQLiteStorageAdapterQueryTest.java
Outdated
Show resolved
Hide resolved
...idTest/java/com/amplifyframework/datastore/storage/sqlite/SQLiteStorageAdapterQueryTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few minor comments to add.
...astore/src/main/java/com/amplifyframework/datastore/storage/sqlite/SQLiteCommandFactory.java
Show resolved
Hide resolved
...astore/src/main/java/com/amplifyframework/datastore/storage/sqlite/SQLiteCommandFactory.java
Outdated
Show resolved
Hide resolved
...astore/src/main/java/com/amplifyframework/datastore/storage/sqlite/SQLiteCommandFactory.java
Outdated
Show resolved
Hide resolved
...astore/src/main/java/com/amplifyframework/datastore/storage/sqlite/SQLiteCommandFactory.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
Issue #, if available:
#2488
Description of changes:
Replace DFS Join Builder with BFS to Improve Alias Management in Joins
How did you test these changes?
(Please add a line here how the changes were tested)
Documentation update required?
General Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.