Fix pagination for models with alias fields

This commit is contained in:
Kobi Tal 2022-11-29 15:06:44 +02:00
parent 09aeddf677
commit d7a26a81bb

View File

@ -319,7 +319,8 @@ class Database(object):
elif page_num < 1: elif page_num < 1:
raise ValueError('Invalid page number: %d' % page_num) raise ValueError('Invalid page number: %d' % page_num)
offset = (page_num - 1) * page_size offset = (page_num - 1) * page_size
query = 'SELECT * FROM $table' query = 'SELECT {} FROM $table'.format(", ".join(model_class.fields().keys()))
if conditions: if conditions:
if isinstance(conditions, Q): if isinstance(conditions, Q):
conditions = conditions.to_sql(model_class) conditions = conditions.to_sql(model_class)