From e2acc94eb629b5326ebefff3a31e3c245f200355 Mon Sep 17 00:00:00 2001 From: Christian Holm Date: Fri, 14 Jun 2013 19:02:20 +0200 Subject: [PATCH] Support API change for SQLAlchemy 0.8 --- fixture/loadable/sqlalchemy_loadable.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fixture/loadable/sqlalchemy_loadable.py b/fixture/loadable/sqlalchemy_loadable.py index 3e14f7e..62872bb 100644 --- a/fixture/loadable/sqlalchemy_loadable.py +++ b/fixture/loadable/sqlalchemy_loadable.py @@ -324,7 +324,13 @@ def save(self, row, column_vals): c = self.conn.execute(stmt, params) else: c = stmt.execute(params) - primary_key = c.last_inserted_ids() + + # In SQLAlchemy 0.8 this changed to a property with another name + if hasattr(c, "primary_key"): + primary_key = c.primary_key + else: + primary_key = c.last_inserted_ids() + if primary_key is None: raise NotImplementedError( "what can we do with a None primary key?")