Skip to content

Commit 3af7bab

Browse files
committed
Merge branch 'main' into develop
2 parents 15dfe23 + 00e1b46 commit 3af7bab

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ I believe that many people who work with FastApi to build RESTful CRUD services
5858

5959
![docs page](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/page_preview.png?raw=true)
6060

61+
## [Developing](https://github.com/LuisLuii/FastAPIQuickCRUD/issues/9)
62+
63+
6164
## Advantages
6265

6366
- [x] **Support SQLAlchemy 1.4** - Allows you build a fully asynchronous or synchronous python service

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from setuptools import setup, find_packages
22

3-
VERSION = '0.1.8'
3+
VERSION = '0.2.0'
44

55
print("""
66

src/fastapi_quickcrud/crud_router.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def crud_router_builder(
4040
dependencies: Optional[List[callable]] = None,
4141
crud_models: Optional[CRUDModel] = None,
4242
async_mode: Optional[bool] = None,
43+
sql_type: Optional[SqlType] = None,
4344
**router_kwargs: Any) -> APIRouter:
4445
"""
4546
:param db_session: Callable function
@@ -107,13 +108,18 @@ def get_transaction_session():
107108

108109
if async_mode is None:
109110
async_mode = inspect.isasyncgen(db_session())
110-
if async_mode:
111+
112+
if sql_type is None:
111113
async def async_runner(f):
112114
return [i.bind.name async for i in f()]
113-
114-
sql_type, = asyncio.get_event_loop().run_until_complete(async_runner(db_session))
115-
else:
116-
sql_type, = [i.bind.name for i in db_session()]
115+
try:
116+
if async_mode:
117+
sql_type, = asyncio.get_event_loop().run_until_complete(async_runner(db_session))
118+
else:
119+
sql_type, = [i.bind.name for i in db_session()]
120+
except Exception:
121+
raise RuntimeError("Some unknown problem occurred error, maybe you are uvicorn.run with reload=True. "
122+
"Try declaring sql_type for crud_router_builder yourself using from fastapi_quickcrud.misc.type import SqlType")
117123

118124
if not crud_methods and NO_PRIMARY_KEY == False:
119125
crud_methods = CrudMethods.get_declarative_model_full_crud_method()

0 commit comments

Comments
 (0)