| 11 | def __init__(self, session: Session): |
| 12 | self.session = session |
| 13 | def _process_result_row(self, row: Row) -> Dict[str, Any]: |
| 14 | result_dict = {} |
| 15 | if isinstance(row, int): |
| 16 | return {'id': row} |
| 17 | if isinstance(row, SQLModel) and not hasattr(row, '_fields'): |
| 18 | return row.model_dump() |
| 19 | for item, key in zip(row, row._fields): |
| 20 | if isinstance(item, SQLModel): |
| 21 | result_dict.update(item.model_dump()) |
| 22 | else: |
| 23 | result_dict[key] = item |
| 24 | |
| 25 | return result_dict |
| 26 | async def paginate( |
| 27 | self, |
| 28 | stmt: Union[Select, SelectOfScalar, Type[ModelT]], |