Skip to content

Commit b05f819

Browse files
committed
Make robust to tables without Primary Keys
Some tables don't have primary keys. In this case `get_pk_constraint` should return something falsey.
1 parent a0ae047 commit b05f819

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

sqlalchemy_monetdb/dialect.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,12 @@ def get_pk_constraint(self, connection, table_name, schema=None, **kw):
369369
args = {"table_id": self._table_id(connection, table_name, schema)}
370370
c = connection.execute(q, args)
371371
table = c.fetchall()
372-
cols = [c[0] for c in table]
373-
name = table[0][1]
374-
return {'constrained_columns': cols, 'name': name}
372+
if table:
373+
cols = [c[0] for c in table]
374+
name = table[0][1]
375+
return {'constrained_columns': cols, 'name': name}
376+
else:
377+
return {}
375378

376379

377380
def get_unique_constraints(self, connection, table_name, schema=None, **kw):

0 commit comments

Comments
 (0)