Fix incorrect foreign key assignment direction on dragging#884
Open
Jadu07 wants to merge 2 commits intodrawdb-io:mainfrom
Open
Fix incorrect foreign key assignment direction on dragging#884Jadu07 wants to merge 2 commits intodrawdb-io:mainfrom
Jadu07 wants to merge 2 commits intodrawdb-io:mainfrom
Conversation
|
@Jadu07 is attempting to deploy a commit to the dottle's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Author
|
@1ilit pls review this pr |
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.
fixes #873
This pull request fixes an issue with how table relationships were created using drag and drop. Earlier, when dragging from a parent table (Primary Key) to a child table (Foreign Key), the generated SQL added the foreign key to the wrong table. Even though the connection looked correct in the UI, the SQL logic behind it was reversed.
The problem was that the system always treated the table where the drag started as the child table. Because of this, the foreign key was assigned to the parent table when users dragged from parent to child.
To fix this, changes were made in src/components/EditorCanvas/Canvas.jsx inside the handleLinking() function. The logic for assigning startTableId and endTableId was updated so that the child table (the Foreign Key holder) is always set as startTableId, and the parent table (the Primary Key holder) is set as endTableId.
With this change, dragging from a Primary Key table to a Foreign Key table now generates correct SQL syntax, where the foreign key is added to the child table as expected. Below are screenshots showing the behavior before and after the fix when running the project locally.
Before (Incorrect SQL syntax):
After (Correct SQL syntax running locally):