Skip to content

Commit 77f98ce

Browse files
make Python 3.4 compatible, also restore requirement for a non-empty primary key
1 parent 47170bc commit 77f98ce

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

datajoint/declare.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ def declare(full_table_name, definition, context):
275275

276276
table_comment, primary_key, attribute_sql, foreign_key_sql, index_sql, external_stores = prepare_declare(
277277
definition, context)
278+
279+
if not primary_key:
280+
raise DataJointError('Table must have a primary key')
281+
278282
return (
279283
'CREATE TABLE IF NOT EXISTS %s (\n' % full_table_name +
280284
',\n'.join(attribute_sql + ['PRIMARY KEY (`' + '`,`'.join(primary_key) + '`)'] + foreign_key_sql + index_sql) +

datajoint/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def suggest(self, *args):
1414
:param args: addition arguments
1515
:return: a new exception of the same type with the additional arguments
1616
"""
17-
return self.__class__(*self.args, *args)
17+
return self.__class__(*(self.args + args))
1818

1919

2020
# --- Second Level ---

tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def setup_package():
116116
db_name = "djtest_blob_migrate"
117117
db_file = "v0_11.sql"
118118
conn_root.query("""
119-
CREATE DATABASE {};
119+
CREATE DATABASE IF NOT EXISTS {};
120120
""".format(db_name))
121121

122122
statements = parse_sql('{}/{}'.format(source, db_file))

0 commit comments

Comments
 (0)