mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
housekeep(fastapi): rework aurweb.db session API
Changes: ------- - Add aurweb.db.get_session() - Returns aurweb.db's global `session` instance - Provides us a way to change the implementation of the session instance without interrupting user code. - Use aurweb.db.get_session() in session API methods - Add docstrings to session API methods - Refactor aurweb.db.delete - Normalize aurweb.db.delete to an alias of session.delete - Refresh instances in places we depend on their non-PK columns being up to date. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
f8ba2c5342
commit
4103ab49c9
22 changed files with 212 additions and 138 deletions
|
@ -279,13 +279,13 @@ def test_connection_execute_paramstyle_unsupported():
|
|||
|
||||
def test_create_delete():
|
||||
with db.begin():
|
||||
db.create(AccountType, AccountType="test")
|
||||
account_type = db.create(AccountType, AccountType="test")
|
||||
|
||||
record = db.query(AccountType, AccountType.AccountType == "test").first()
|
||||
assert record is not None
|
||||
|
||||
with db.begin():
|
||||
db.delete(AccountType, AccountType.AccountType == "test")
|
||||
db.delete(account_type)
|
||||
|
||||
record = db.query(AccountType, AccountType.AccountType == "test").first()
|
||||
assert record is None
|
||||
|
@ -306,7 +306,7 @@ def test_add_commit():
|
|||
|
||||
# Remove the record.
|
||||
with db.begin():
|
||||
db.delete(AccountType, AccountType.ID == account_type.ID)
|
||||
db.delete(account_type)
|
||||
|
||||
|
||||
def test_connection_executor_mysql_paramstyle():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue