Merge pull request #197 from Infinidat/fix_paginate_alias

Fix pagination for models with alias fields
This commit is contained in:
Kobi Tal 2022-11-29 15:08:45 +02:00 committed by GitHub
commit 070b2c3ff4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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