Skip to content

Commit 1ab733c

Browse files
Fix styling.
1 parent 31a371a commit 1ab733c

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

datajoint/table.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -351,32 +351,34 @@ def _delete_cascade(self):
351351
try:
352352
# try to parse error for child info
353353
match = foreign_key_full_error_regexp.match(error.args[0]).groupdict()
354-
if "`.`" not in match['child']: # if schema name is not included, use self
354+
if "`.`" not in match['child']: # if schema name missing, use self
355355
match['child'] = '{}.{}'.format(self.full_table_name.split(".")[0],
356356
match['child'])
357357
match['fk_attrs'] = [k.strip('`') for k in match['fk_attrs'].split(',')]
358358
match['pk_attrs'] = [k.strip('`') for k in match['pk_attrs'].split(',')]
359359
except AttributeError:
360360
# additional query required due to truncated error, trying partial regex
361361
match = foreign_key_partial_error_regexp.match(error.args[0]).groupdict()
362-
if "`.`" not in match['child']: # if schema name is not included, use self
362+
if "`.`" not in match['child']: # if schema name missing, use self
363363
match['child'] = '{}.{}'.format(self.full_table_name.split(".")[0],
364364
match['child'])
365-
match['fk_attrs'], match['parent'], match['pk_attrs'] = list(map(list, zip(
366-
*self.connection.query(
367-
"""
368-
SELECT
369-
COLUMN_NAME as fk_attrs,
370-
CONCAT('`', REFERENCED_TABLE_SCHEMA, '`.`',
371-
REFERENCED_TABLE_NAME, '`') as parent,
372-
REFERENCED_COLUMN_NAME as pk_attrs
373-
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
374-
WHERE
375-
CONSTRAINT_NAME = %s AND TABLE_SCHEMA = %s AND TABLE_NAME = %s;
376-
""",
377-
args=(match['name'].strip('`'),
378-
*[_.strip('`') for _ in match['child'].split('`.`')])
379-
).fetchall())))
365+
match['fk_attrs'], match['parent'], match['pk_attrs'] = list(map(
366+
list, zip(
367+
*self.connection.query(
368+
"""
369+
SELECT
370+
COLUMN_NAME as fk_attrs,
371+
CONCAT('`', REFERENCED_TABLE_SCHEMA, '`.`',
372+
REFERENCED_TABLE_NAME, '`') as parent,
373+
REFERENCED_COLUMN_NAME as pk_attrs
374+
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
375+
WHERE
376+
CONSTRAINT_NAME = %s AND TABLE_SCHEMA = %s
377+
AND TABLE_NAME = %s;
378+
""",
379+
args=(match['name'].strip('`'),
380+
*[_.strip('`') for _ in match['child'].split('`.`')])
381+
).fetchall())))
380382
match['parent'] = match['parent'][0]
381383
# restrict child by self if
382384
# 1. if self's restriction attributes are not in child's primary key
@@ -403,8 +405,10 @@ def _delete_cascade(self):
403405
def delete(self, transaction=True, safemode=None):
404406
"""
405407
Deletes the contents of the table and its dependent tables, recursively.
408+
406409
:param transaction: if True, use the entire delete becomes an atomic transaction.
407-
:param safemode: If True, prohibit nested transactions and prompt to confirm. Default is dj.config['safemode'].
410+
:param safemode: If True, prohibit nested transactions and prompt to confirm. Default
411+
is dj.config['safemode'].
408412
"""
409413
safemode = config['safemode'] if safemode is None else safemode
410414

0 commit comments

Comments
 (0)