Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nk20
Manage
Activity
Members
Labels
Plan
Issues
31
Issue boards
Milestones
Wiki
Code
Merge requests
6
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BDE
nk20
Commits
8db9e929
Commit
8db9e929
authored
4 years ago
by
ynerant
Browse files
Options
Downloads
Patches
Plain Diff
Sqlite does not support order by in subqueries
parent
3e42f4ff
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!107
Beta
Pipeline
#8597
passed with stages
in 12 minutes and 44 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/api/urls.py
+7
-1
7 additions, 1 deletion
apps/api/urls.py
apps/note/api/views.py
+5
-2
5 additions, 2 deletions
apps/note/api/views.py
with
12 additions
and
3 deletions
apps/api/urls.py
+
7
−
1
View file @
8db9e929
...
@@ -51,7 +51,10 @@ class UserViewSet(ReadProtectedModelViewSet):
...
@@ -51,7 +51,10 @@ class UserViewSet(ReadProtectedModelViewSet):
filterset_fields
=
[
'
id
'
,
'
username
'
,
'
first_name
'
,
'
last_name
'
,
'
email
'
,
'
is_superuser
'
,
'
is_staff
'
,
'
is_active
'
,
]
filterset_fields
=
[
'
id
'
,
'
username
'
,
'
first_name
'
,
'
last_name
'
,
'
email
'
,
'
is_superuser
'
,
'
is_staff
'
,
'
is_active
'
,
]
def
get_queryset
(
self
):
def
get_queryset
(
self
):
queryset
=
super
().
get_queryset
().
order_by
(
"
username
"
)
queryset
=
super
().
get_queryset
()
# Sqlite doesn't support ORDER BY in subqueries
queryset
=
queryset
.
order_by
(
"
username
"
)
\
if
settings
.
DATABASES
[
queryset
.
db
][
"
ENGINE
"
]
==
'
django.db.backends.postgresql
'
else
queryset
if
"
search
"
in
self
.
request
.
GET
:
if
"
search
"
in
self
.
request
.
GET
:
pattern
=
self
.
request
.
GET
[
"
search
"
]
pattern
=
self
.
request
.
GET
[
"
search
"
]
...
@@ -87,6 +90,9 @@ class UserViewSet(ReadProtectedModelViewSet):
...
@@ -87,6 +90,9 @@ class UserViewSet(ReadProtectedModelViewSet):
),
),
all
=
True
)
all
=
True
)
queryset
=
queryset
if
settings
.
DATABASES
[
queryset
.
db
][
"
ENGINE
"
]
==
'
django.db.backends.postgresql
'
\
else
queryset
.
order_by
(
"
username
"
)
return
queryset
return
queryset
...
...
This diff is collapsed.
Click to expand it.
apps/note/api/views.py
+
5
−
2
View file @
8db9e929
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-License-Identifier: GPL-3.0-or-later
from
django.conf
import
settings
from
django.db.models
import
Q
from
django.db.models
import
Q
from
django.core.exceptions
import
ValidationError
from
django.core.exceptions
import
ValidationError
from
django_filters.rest_framework
import
DjangoFilterBackend
from
django_filters.rest_framework
import
DjangoFilterBackend
...
@@ -117,6 +117,9 @@ class ConsumerViewSet(ReadOnlyProtectedModelViewSet):
...
@@ -117,6 +117,9 @@ class ConsumerViewSet(ReadOnlyProtectedModelViewSet):
"""
"""
queryset
=
super
().
get_queryset
()
queryset
=
super
().
get_queryset
()
# Sqlite doesn't support ORDER BY in subqueries
queryset
=
queryset
.
order_by
(
"
username
"
)
\
if
settings
.
DATABASES
[
queryset
.
db
][
"
ENGINE
"
]
==
'
django.db.backends.postgresql
'
else
queryset
alias
=
self
.
request
.
query_params
.
get
(
"
alias
"
,
"
.*
"
)
alias
=
self
.
request
.
query_params
.
get
(
"
alias
"
,
"
.*
"
)
queryset
=
queryset
.
prefetch_related
(
'
note
'
)
queryset
=
queryset
.
prefetch_related
(
'
note
'
)
...
@@ -137,7 +140,7 @@ class ConsumerViewSet(ReadOnlyProtectedModelViewSet):
...
@@ -137,7 +140,7 @@ class ConsumerViewSet(ReadOnlyProtectedModelViewSet):
),
),
all
=
True
)
all
=
True
)
return
queryset
.
order_by
(
'
name
'
).
distinct
()
return
queryset
.
distinct
()
class
TemplateCategoryViewSet
(
ReadProtectedModelViewSet
):
class
TemplateCategoryViewSet
(
ReadProtectedModelViewSet
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment