Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
f730d811
Commit
f730d811
authored
Aug 19, 2015
by
Guillaume Pratte
Committed by
Guillaume Pratte
Aug 22, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement order_by option in SQL Alchemy QueryAjaxModelLoader
This is to support offset() with Microsoft SQL Server.
parent
691a1c98
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
0 deletions
+4
-0
ajax.py
flask_admin/contrib/sqla/ajax.py
+4
-0
No files found.
flask_admin/contrib/sqla/ajax.py
View file @
f730d811
...
...
@@ -17,6 +17,7 @@ class QueryAjaxModelLoader(AjaxModelLoader):
self
.
session
=
session
self
.
model
=
model
self
.
fields
=
options
.
get
(
'fields'
)
self
.
order_by
=
options
.
get
(
'order_by'
)
if
not
self
.
fields
:
raise
ValueError
(
'AJAX loading requires `fields` to be specified for
%
s.
%
s'
%
(
model
,
self
.
name
))
...
...
@@ -61,6 +62,9 @@ class QueryAjaxModelLoader(AjaxModelLoader):
filters
=
(
field
.
ilike
(
u'
%%%
s
%%
'
%
term
)
for
field
in
self
.
_cached_fields
)
query
=
query
.
filter
(
or_
(
*
filters
))
if
self
.
order_by
:
query
=
query
.
order_by
(
self
.
order_by
)
return
query
.
offset
(
offset
)
.
limit
(
limit
)
.
all
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment