Skip to content

Commit 43fabad

Browse files
fix error message for the case when attempting to delete without the REFERENCE privilege
1 parent e71418d commit 43fabad

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

datajoint/autopopulate.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def make(self, key):
9898
9999
1. Fetch data from tables above in the dependency hierarchy, restricted by the given key.
100100
2. Compute secondary attributes based on the fetched data.
101-
3. Insert the new tuples into the current table.
101+
3. Insert the new tuple(s) into the current table.
102102
103103
The method can be implemented either as:
104104
(a) Regular method: All three steps are performed in a single database transaction.
@@ -263,9 +263,8 @@ def populate(
263263
self.connection.schemas[self.target.database].jobs if reserve_jobs else None
264264
)
265265

266-
# define and set up signal handler for SIGTERM:
267266
if reserve_jobs:
268-
267+
# Define a signal handler for SIGTERM
269268
def handler(signum, frame):
270269
logger.info("Populate terminated by SIGTERM")
271270
raise SystemExit("SIGTERM received")

datajoint/declare.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def declare(full_table_name, definition, context):
302302
name=table_name, max_length=MAX_TABLE_NAME_LENGTH
303303
)
304304
)
305-
305+
306306
(
307307
table_comment,
308308
primary_key,

datajoint/table.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def alter(self, prompt=True, context=None):
135135
sql, external_stores = alter(self.definition, old_definition, context)
136136
if not sql:
137137
if prompt:
138-
logger.warn("Nothing to alter.")
138+
logger.warning("Nothing to alter.")
139139
else:
140140
sql = "ALTER TABLE {tab}\n\t".format(
141141
tab=self.full_table_name
@@ -518,7 +518,13 @@ def cascade(table):
518518
try:
519519
delete_count = table.delete_quick(get_count=True)
520520
except IntegrityError as error:
521-
match = foreign_key_error_regexp.match(error.args[0]).groupdict()
521+
match = foreign_key_error_regexp.match(error.args[0])
522+
if match is None:
523+
raise DataJointError(
524+
"Cascading deletes failed because the error message is missing foreign key information."
525+
"Make sure you have REFERENCES privilege to all dependent tables."
526+
) from None
527+
match = match.groupdict()
522528
# if schema name missing, use table
523529
if "`.`" not in match["child"]:
524530
match["child"] = "{}.{}".format(
@@ -641,7 +647,7 @@ def cascade(table):
641647
# Confirm and commit
642648
if delete_count == 0:
643649
if safemode:
644-
logger.warn("Nothing to delete.")
650+
logger.warning("Nothing to delete.")
645651
if transaction:
646652
self.connection.cancel_transaction()
647653
elif not transaction:
@@ -651,12 +657,12 @@ def cascade(table):
651657
if transaction:
652658
self.connection.commit_transaction()
653659
if safemode:
654-
logger.info("Deletes committed.")
660+
logger.info("Delete committed.")
655661
else:
656662
if transaction:
657663
self.connection.cancel_transaction()
658664
if safemode:
659-
logger.warn("Deletes cancelled")
665+
logger.warning("Delete cancelled")
660666
return delete_count
661667

662668
def drop_quick(self):
@@ -724,11 +730,6 @@ def size_on_disk(self):
724730
).fetchone()
725731
return ret["Data_length"] + ret["Index_length"]
726732

727-
def show_definition(self):
728-
raise AttributeError(
729-
"show_definition is deprecated. Use the describe method instead."
730-
)
731-
732733
def describe(self, context=None, printout=False):
733734
"""
734735
:return: the definition string for the query using DataJoint DDL.

0 commit comments

Comments
 (0)