This commit is contained in:
yumoqing 2023-06-01 15:06:09 +08:00
parent 2d13889a26
commit 12921c70ca
6 changed files with 8 additions and 34 deletions

View File

@ -66,7 +66,7 @@ class MsSqlor(SQLor):
def pagingSQLmodel(self):
return u"""select *
from (
select row_number() over(order by $[sort]$ $[order]$) as _row_id,page_s.*
select row_number() over(order by $[sort]$) as _row_id,page_s.*
from (%s) page_s
) A
where _row_id >= $[from_line]$ and _row_id < $[end_line]$"""

View File

@ -71,35 +71,8 @@ class MySqlor(SQLor):
d = [ i['value'] for i in dataList]
return tuple(d)
def pagingSQL(self,sql,paging,NS):
"""
default it not support paging
"""
page = int(NS.get(paging['pagename'],1))
rows = int(NS.get(paging['rowsname'],ROWS))
sort = NS.get(paging.get('sortname','sort'),None)
order = NS.get(paging.get('ordername','asc'),'asc')
if not sort:
return sql
if page < 1:
page = 1
from_line = (page - 1) * rows
end_line = page * rows + 1
psql = self.pagingSQLmodel()
ns={
'from_line':from_line,
'end_line':end_line,
'rows':rows,
'sort':sort,
'order':order,
}
ac = ArgsConvert('$[',']$')
psql = ac.convert(psql,ns)
retSQL=psql % sql
return retSQL
def pagingSQLmodel(self):
return u"""select * from (%s) A order by $[sort]$ $[order]$
return u"""select * from (%s) A order by $[sort]$
limit $[from_line]$,$[rows]$"""
def tablesSQL(self):

View File

@ -62,7 +62,7 @@ class Oracleor(SQLor):
from (
select page_s.*,rownum row_id
from (%s) page_s
order by $[sort]$ $[order]$
order by $[sort]$
)
where row_id >=$[from_line]$ and row_id < $[end_line]$"""

View File

@ -61,7 +61,7 @@ class PostgreSQLor(SQLor):
from (
select page_s.*,rownum row_id
from (%s) page_s
order by $[sort]$ $[order]$
order by $[sort]$
)
where row_id >=$[from_line]$ and row_id < $[end_line]$"""

View File

@ -181,7 +181,8 @@ class SQLor(object):
page = int(NS.get(paging['pagename'],1))
rows = int(NS.get(paging['rowsname'],ROWS))
sort = NS.get(paging.get('sortname','sort'),None)
order = NS.get(paging.get('ordername','asc'),'asc')
if isinstance(sort, dict):
sort = ','.join(sort)
if not sort:
return sql
if page < 1:
@ -194,7 +195,7 @@ class SQLor(object):
'end_line':end_line,
'rows':rows,
'sort':sort,
'order':order,
'order':'',
}
ac = ArgsConvert('$[',']$')
psql = ac.convert(psql,ns)

View File

@ -38,7 +38,7 @@ class SQLite3or(SQLor):
return tuple(d)
def pagingSQLmodel(self):
sql = u"""select * from (%s) order by $[sort]$ $[order]$ limit $[from_line]$,$[end_line]$"""
sql = u"""select * from (%s) order by $[sort]$ limit $[from_line]$,$[end_line]$"""
return sql
def tablesSQL(self):