Upgrade Peewee to latest 3.x
This requires a number of small changes in the data model code, as well as additional testing.
This commit is contained in:
parent
70b7ee4654
commit
d3d9cca182
26 changed files with 220 additions and 193 deletions
|
@ -8,7 +8,7 @@ from flask import Flask, jsonify
|
|||
from flask_login import LoginManager
|
||||
from flask_principal import identity_loaded, Permission, Identity, identity_changed, Principal
|
||||
from flask_mail import Mail
|
||||
from peewee import SqliteDatabase, savepoint, InternalError
|
||||
from peewee import SqliteDatabase, InternalError
|
||||
|
||||
from app import app as application
|
||||
from auth.permissions import on_identity_loaded
|
||||
|
@ -147,19 +147,20 @@ def initialized_db(appconfig):
|
|||
# If under a test *real* database, setup a savepoint.
|
||||
under_test_real_database = bool(os.environ.get('TEST_DATABASE_URI'))
|
||||
if under_test_real_database:
|
||||
test_savepoint = savepoint(db)
|
||||
test_savepoint.__enter__()
|
||||
with db.transaction():
|
||||
test_savepoint = db.savepoint()
|
||||
test_savepoint.__enter__()
|
||||
|
||||
yield # Run the test.
|
||||
yield # Run the test.
|
||||
|
||||
try:
|
||||
test_savepoint.rollback()
|
||||
test_savepoint.__exit__(None, None, None)
|
||||
except InternalError:
|
||||
# If postgres fails with an exception (like IntegrityError) mid-transaction, it terminates
|
||||
# it immediately, so when we go to remove the savepoint, it complains. We can safely ignore
|
||||
# this case.
|
||||
pass
|
||||
try:
|
||||
test_savepoint.rollback()
|
||||
test_savepoint.__exit__(None, None, None)
|
||||
except InternalError:
|
||||
# If postgres fails with an exception (like IntegrityError) mid-transaction, it terminates
|
||||
# it immediately, so when we go to remove the savepoint, it complains. We can safely ignore
|
||||
# this case.
|
||||
pass
|
||||
else:
|
||||
yield
|
||||
|
||||
|
|
Reference in a new issue