Open samuelbray32 opened 11 months ago
@dimitri-yatsenko Just checking in on this, as it's a bit of a challenge for users not to be able to delete entries from our comment tables. Any ideas?
fixed in #1112
Unfortunately, errors persist for users with insufficient privileges. I did not see the error when testing with the first account listed below, but I do see it with the second.
mysql> show grants for 'cbroz';
+------------------------------------------------------------+
| Grants for cbroz@% |
+------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON `%`.* TO `cbroz`@`%` |
...
mysql> show grants for 'cbroz-basic';
+------------------------------------------------------------+
| Grants for cbroz-basic@% |
+------------------------------------------------------------+
| GRANT SELECT ON `%`.* TO `cbroz-basic`@`%` |
When DataJoint catches MySQL 8 error 1217
, MySQL is not giving sufficient information to continue the cascade:
Cell In[4], line 1
----> 1 from spyglass.common import IntervalList; (IntervalList & 'nwb_file_name LIKE "SC3820230606_.nwb%"').delete()
File ~/wrk/datajoint-python/datajoint/table.py:586, in Table.delete(self, transaction, safemode, force_parts)
584 # Cascading delete
585 try:
--> 586 delete_count = cascade(self)
587 except:
588 if transaction:
File ~/wrk/datajoint-python/datajoint/table.py:506, in Table.delete.<locals>.cascade(table)
504 delete_count = table.delete_quick(get_count=True)
505 except IntegrityError as error:
--> 506 match = foreign_key_error_regexp.match(error.args[0]).groupdict()
507 if "`.`" not in match["child"]: # if schema name missing, use table
508 match["child"] = "{}.{}".format(
509 table.full_table_name.split(".")[0], match["child"]
510 )
AttributeError: 'NoneType' object has no attribute 'groupdict'
What would you suggest @dimitri-yatsenko? Is there a way to continue the cascade without granting additional privileges for the user?
Bug Report
Description
delete_quick
not being caught in thecascade
function indelete
, which is why all the children need deleted before can delete a table.Reproducibility
Linux
Python Version: 3.9.16
MySQL Version: 8.0.34
MySQL Deployment Strategy: remote
DataJoint Version: 0.14.1
Minimum number of steps to reliably reproduce the issue: Error only occurs for some users. Occurs when calling
TableName.delete({restriction})
on a table with child tables populated for the restrictionExample error stack
Expected Behavior
A deletion of the row entry and all dependent entries in child tables
Additional Research and Context
I'm not entirely sure where the change is in MySQL, but this seems related to this post here