Skip to content

Commit

Permalink
feat!: orm_threadpool&orm_async: fully re-implement, now fully suppor…
Browse files Browse the repository at this point in the history
…t all APIs in orm_base (#54)

This PR fully re-implements the orm_threadpool and orm_async implementation, simplifies and reduce boilerplate code by implementing generic wrapping helpers for wrapping single-thread APIs from ORMBase within thread context.
Two types of wrapping helpers are implemented, one is for APIs returing value, another one is for APIs returning generator.

Also, considering the typing complexity, this PR splits the ORMBase.orm_delete_entries into two new methods:
1. the normal version of orm_delete_entries which returns deleted row count.
2. orm_delete_entries_with_returning, which enables returning stmt on DELETE.

With the help of the new mechanism introduced by this PR, now all APIs from ORMBase(except for orm_con) are supported in orm_threadpool and orm_async.

BREAKING: now ORMThreadPool and AsyncORMThreadPool are NOT subclass of ORMBase anymore, they are standalone separated types.

BREAKING: for users previously using ORMBase.orm_delete_entries with returning stmt, now they should switch to use ORMBase.orm_delete_entries_with_returning.
  • Loading branch information
pga2rn authored Dec 15, 2024
1 parent a42441f commit af30f3c
Show file tree
Hide file tree
Showing 9 changed files with 386 additions and 515 deletions.
4 changes: 2 additions & 2 deletions src/simple_sqlite3_orm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from simple_sqlite3_orm._orm import (
AsyncORMThreadPoolBase,
AsyncORMBase,
ORMBase,
ORMBaseType,
ORMThreadPoolBase,
Expand Down Expand Up @@ -32,7 +32,7 @@
"TypeAffinityRepr",
"TableSpec",
"TableSpecType",
"AsyncORMThreadPoolBase",
"AsyncORMBase",
"ORMBase",
"ORMBaseType",
"ORMThreadPoolBase",
Expand Down
4 changes: 2 additions & 2 deletions src/simple_sqlite3_orm/_orm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from simple_sqlite3_orm._orm._async import AsyncORMThreadPoolBase
from simple_sqlite3_orm._orm._async import AsyncORMBase
from simple_sqlite3_orm._orm._base import ORMBase, ORMBaseType
from simple_sqlite3_orm._orm._multi_thread import ORMThreadPoolBase

__all__ = ["AsyncORMThreadPoolBase", "ORMBase", "ORMThreadPoolBase", "ORMBaseType"]
__all__ = ["AsyncORMBase", "ORMBase", "ORMThreadPoolBase", "ORMBaseType"]
Loading

1 comment on commit af30f3c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/simple_sqlite3_orm
   __init__.py70100% 
   _sqlite_spec.py360100% 
   _table_spec.py1873581%49, 58, 69, 73–74, 86, 98, 115, 174, 179–181, 221, 302, 304, 306–307, 355, 358, 362–364, 366–370, 372, 378, 421–422, 532–533, 547–548
   _types.py22195%31
   _utils.py681085%40, 42–43, 46–47, 69, 82, 85, 95, 108
   utils.py1203670%127, 134–135, 170–173, 219, 232, 252–256, 282, 286, 327, 332–339, 351–353, 355–356, 359, 361–363, 372–373
src/simple_sqlite3_orm/_orm
   __init__.py40100% 
   _async.py93990%34, 74, 76–77, 90–91, 93, 144, 148
   _base.py117794%107, 162, 264, 304, 386, 426, 449
   _multi_thread.py1061090%32, 34–35, 70, 72–73, 86–87, 89, 134
TOTAL76010885% 

Tests Skipped Failures Errors Time
72 0 💤 0 ❌ 0 🔥 2m 5s ⏱️

Please sign in to comment.