File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -108,13 +108,18 @@ def get_transaction_session():
108108
109109 if async_mode is None :
110110 async_mode = inspect .isasyncgen (db_session ())
111- if async_mode :
111+
112+ if sql_type is None :
112113 async def async_runner (f ):
113114 return [i .bind .name async for i in f ()]
114- if sql_type is None :
115- sql_type , = asyncio .get_event_loop ().run_until_complete (async_runner (db_session ))
116- elif sql_type is None :
117- 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" )
118123
119124 if not crud_methods and NO_PRIMARY_KEY == False :
120125 crud_methods = CrudMethods .get_declarative_model_full_crud_method ()
You can’t perform that action at this time.
0 commit comments