From f525da0cb39c374ce4f7b6f4bf272821b9ed3e48 Mon Sep 17 00:00:00 2001 From: Olly Cope Date: Tue, 11 Oct 2022 19:47:46 +0000 Subject: Guard against exceptions inside _check_transactional_ddl This implements the fix suggested here https://todo.sr.ht/~olly/yoyo/71, necessary for use with Cockroach DB. --- yoyo/backends/base.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/yoyo/backends/base.py b/yoyo/backends/base.py index 3c1f9a7..4f95a66 100644 --- a/yoyo/backends/base.py +++ b/yoyo/backends/base.py @@ -237,9 +237,13 @@ class DatabaseBackend: table_name = "yoyo_tmp_{}".format(utils.get_random_string(10)) table_name_quoted = self.quote_identifier(table_name) sql = self.create_test_table_sql.format(table_name_quoted=table_name_quoted) - with self.transaction() as t: - self.execute(sql) - t.rollback() + try: + with self.transaction() as t: + self.execute(sql) + t.rollback() + except self.DatabaseError: + return False + try: with self.transaction(): self.execute("DROP TABLE {}".format(table_name_quoted)) -- cgit v1.2.1