summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlly Cope <olly@ollycope.com>2022-10-11 19:47:46 +0000
committerOlly Cope <olly@ollycope.com>2022-10-11 19:47:46 +0000
commitf525da0cb39c374ce4f7b6f4bf272821b9ed3e48 (patch)
tree8d641fb6d62456d76619a4dc3a8d3d90f6d33d8e
parent6a01da3deb23af5a98c67e4f120d695a09b3e4bf (diff)
downloadyoyo-f525da0cb39c374ce4f7b6f4bf272821b9ed3e48.tar.gz
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.
-rw-r--r--yoyo/backends/base.py10
1 files 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))