File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed
fastapi_jsonapi/data_layers/sqla Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change 1111from fastapi_jsonapi .data_layers .sqla .query_building import RelationshipInfo
1212from fastapi_jsonapi .data_typing import TypeModel
1313from fastapi_jsonapi .exceptions import BadRequest , InternalServerError , ObjectNotFound
14+ from fastapi_jsonapi .storages .models_storage import models_storage
1415
1516log = logging .getLogger (__name__ )
1617
@@ -97,8 +98,10 @@ async def count(
9798 cls ,
9899 session : AsyncSession ,
99100 stmt : Select ,
101+ resource_type : str ,
100102 ) -> int :
101- stmt = select (func .count (distinct (column ("id" )))).select_from (stmt .subquery ())
103+ id_col = models_storage .get_model_id_field_name (resource_type )
104+ stmt = select (func .count (distinct (column (id_col )))).select_from (stmt .subquery ())
102105 return (await session .execute (stmt )).scalar_one ()
103106
104107 @classmethod
Original file line number Diff line number Diff line change @@ -428,6 +428,7 @@ async def get_collection(
428428 objects_count = await self ._base_sql .count (
429429 session = self .session ,
430430 stmt = query ,
431+ resource_type = self .resource_type ,
431432 )
432433
433434 collection = await self .after_get_collection (collection , qs , view_kwargs )
You can’t perform that action at this time.
0 commit comments