Skip to content

Fix sqldriver to not delete NON update_cascade children #134

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

Merged
merged 2 commits into from
Mar 7, 2023
Merged

Fix sqldriver to not delete NON update_cascade children #134

merged 2 commits into from
Mar 7, 2023

Conversation

ssweber
Copy link
Collaborator

@ssweber ssweber commented Mar 7, 2023

I found when testing 'PRAGMA foreign_keys = ON' that current sqldriver was deleting records that only used foreign-key in drop-downs.. not as update_cascade

I found when testing 'PRAGMA foreign_keys = ON' that current sqldriver was deleting records that only used foreign-key in drop-downs.. not as update_cascade
@ssweber ssweber mentioned this pull request Mar 7, 2023
Added the 'children deleted' list to delete, like it has in duplicate... otherwise there can be multiple deletes to the same table.

Added a popup for exceptions to delete.
@@ -4335,7 +4340,7 @@ def delete_record(self, dataset: DataSet, cascade=True): # TODO: get ON DELETE C
table = self.quote_table(dataset.table)
pk_column = self.quote_column(dataset.pk_column)
q = f'DELETE FROM {table} WHERE {pk_column}={dataset.get_current(dataset.pk_column)};'
self.execute(q)
return self.execute(q)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This really is only popups an exception on the parent execute. I figure you’re going to rework this a bit for delete_cascade / to be recursive.

@PySimpleSQL PySimpleSQL merged commit 872f4a8 into PySimpleSQL:development Mar 7, 2023
@ssweber ssweber deleted the fix-delete branch March 8, 2023 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants