Paginación de access
This commit is contained in:
@@ -426,6 +426,31 @@ class SQLCompiler(object):
|
||||
self.get_group_by(),
|
||||
self.get_limits(), ") as tbl_paginated WHERE ", conds]
|
||||
|
||||
if self.sql_mode == "ACCESS" and self._limits and \
|
||||
self._limits.start is not None and self._limits.stop is not None:
|
||||
conds = []
|
||||
|
||||
if self._limits.start is not None:
|
||||
conds.append("row_number > %s" % self._limits.start)
|
||||
|
||||
if self._limits.stop is not None:
|
||||
conds.append("row_number <= %s" % self._limits.stop)
|
||||
|
||||
conds = " AND ".join(conds)
|
||||
count = "(select count(*) FROM {table} as t2 WHERE t2.{id} <= {table}.{id}) as row_number".format(table=table,
|
||||
id=self._order_by[0])
|
||||
|
||||
return ["SELECT * FROM (", "SELECT", self.get_columns(), ",",
|
||||
count,
|
||||
# "FROM",
|
||||
# table,
|
||||
self.get_joins(),
|
||||
self.get_where(),
|
||||
self.get_group_by(),
|
||||
" FROM ",
|
||||
table,
|
||||
") WHERE ", conds]
|
||||
|
||||
return sql
|
||||
|
||||
def _compile(self):
|
||||
@@ -436,7 +461,7 @@ class SQLCompiler(object):
|
||||
|
||||
__str__ = __repr__
|
||||
|
||||
@property
|
||||
@ property
|
||||
def sql(self,):
|
||||
return self.__str__()
|
||||
|
||||
@@ -450,6 +475,6 @@ class Queryset(SQLCompiler, SQLQuery):
|
||||
|
||||
class SQLModel(object):
|
||||
|
||||
@classproperty
|
||||
@ classproperty
|
||||
def objects(cls):
|
||||
return Queryset(cls.table, getattr(cls, 'sql_mode', None))
|
||||
|
||||
Reference in New Issue
Block a user