Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
f30d42e0
Commit
f30d42e0
authored
9 years ago
by
Tom Robinson
Browse files
Options
Downloads
Patches
Plain Diff
Fix ability to sort by grouped fk-> or datetime_field field
Resolves #1641
parent
e15571ea
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/lib/query.js
+27
-6
27 additions, 6 deletions
frontend/src/lib/query.js
with
27 additions
and
6 deletions
frontend/src/lib/query.js
+
27
−
6
View file @
f30d42e0
import
inflection
from
"
inflection
"
;
import
_
from
"
underscore
"
;
var
Query
=
{
...
...
@@ -65,7 +66,7 @@ var Query = {
}
}
else
if
(
Query
.
hasValidBreakout
(
query
))
{
// remove sort if it references a non-broken-out field
if
(
query
.
breakout
.
filter
(
b
=>
b
===
field
).
length
===
0
)
{
if
(
query
.
breakout
.
filter
(
b
=>
Query
.
isSameField
(
b
,
field
)
)
.
length
===
0
)
{
return
false
;
}
}
else
if
(
!
Query
.
isBareRowsAggregation
(
query
))
{
...
...
@@ -272,12 +273,14 @@ var Query = {
}
else
if
(
Query
.
hasValidBreakout
(
query
))
{
// further filter field list down to only fields in our breakout clause
var
breakoutFieldList
=
[];
query
.
breakout
.
map
(
function
(
breakoutFieldId
)
{
for
(
var
idx
in
fields
)
{
if
(
fields
[
idx
].
id
===
breakoutFieldId
)
{
breakoutFieldList
.
push
(
fields
[
idx
]);
query
.
breakout
.
map
(
function
(
breakoutField
)
{
let
breakoutFieldId
=
Query
.
getFieldTargetId
(
breakoutField
);
fields
.
map
(
function
(
field
)
{
if
(
field
.
id
===
breakoutFieldId
)
{
breakoutFieldList
.
push
(
field
);
}
}
}
);
});
if
(
Query
.
canSortByAggregateField
(
query
))
{
...
...
@@ -347,6 +350,24 @@ var Query = {
);
},
isSameField
:
function
(
fieldA
,
fieldB
)
{
// TODO: should this be less strict, e.x. datetime_field might be considered same as raw field?
return
_
.
isEqual
(
fieldA
,
fieldB
);
},
getFieldTargetId
:
function
(
field
)
{
if
(
Array
.
isArray
(
field
))
{
if
(
field
[
0
]
===
"
fk->
"
)
{
return
field
[
2
];
}
if
(
field
[
0
]
===
"
datetime_field
"
)
{
return
field
[
1
];
}
}
else
{
return
field
;
}
},
getFieldTarget
:
function
(
field
,
tableMetadata
)
{
let
table
,
fieldId
,
fk
;
if
(
Array
.
isArray
(
field
)
&&
field
[
0
]
===
"
fk->
"
)
{
...
...
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