mirror of
https://github.com/fastapi-practices/fastapi_best_architecture.git
synced 2026-03-13 09:31:31 +08:00
Optimize the serialize return of SQLA select (#436)
This commit is contained in:
@@ -57,7 +57,6 @@ def select_as_dict(row: R, use_alias: bool = False) -> dict:
|
||||
result = row.__dict__
|
||||
if '_sa_instance_state' in result:
|
||||
del result['_sa_instance_state']
|
||||
return result
|
||||
else:
|
||||
result = {}
|
||||
mapper = class_mapper(row.__class__)
|
||||
@@ -65,7 +64,8 @@ def select_as_dict(row: R, use_alias: bool = False) -> dict:
|
||||
if isinstance(prop, (ColumnProperty, SynonymProperty)):
|
||||
key = prop.key
|
||||
result[key] = getattr(row, key)
|
||||
return result
|
||||
|
||||
return result
|
||||
|
||||
|
||||
class MsgSpecJSONResponse(JSONResponse):
|
||||
|
||||
Reference in New Issue
Block a user