Skip to content

Commit

Permalink
feat: use NewDatabaseSchemaError for another exc type (#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Jan 10, 2024
1 parent 49c6e9c commit 1f3cd9b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions y/_db/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import os

from pony.orm import Database, BindingError, OperationalError, TransactionError
from pony.orm import Database, BindingError, DatabaseError, TransactionError

from y._db.config import SQLITE_PATH

Expand All @@ -16,11 +16,10 @@ def bind_db(db: Database, **connection_settings) -> None:
def generate_mapping(db: Database) -> None:
try:
db.generate_mapping(create_tables=True)
except OperationalError as e:
if "no such column: " in str(e):
except DatabaseError as e:
if "no such column: " in str(e) or ("column" in str(e) and " does not exist" in str(e)):
from y._db.exceptions import NewDatabaseSchemaError
raise NewDatabaseSchemaError from e
raise e
except TransactionError as e:
if str(e) != "@db_session-decorated create_tables() function with `ddl` option cannot be called inside of another db_session":
raise e
Expand Down

0 comments on commit 1f3cd9b

Please sign in to comment.