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
3bc463df
Unverified
Commit
3bc463df
authored
1 year ago
by
metamben
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Return card__<id> for non-model cards and FK targets for tables (#38378)
Fixes #38312.
parent
b5af8b9b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/lib/fe_util.cljc
+17
-10
17 additions, 10 deletions
src/metabase/lib/fe_util.cljc
test/metabase/lib/fe_util_test.cljc
+6
-2
6 additions, 2 deletions
test/metabase/lib/fe_util_test.cljc
with
23 additions
and
12 deletions
src/metabase/lib/fe_util.cljc
+
17
−
10
View file @
3bc463df
...
...
@@ -112,6 +112,14 @@
_
(
lib.metadata.calculation/display-name
query
stage-number
filter-clause
))))
(
defn-
foreign-key-items
[
columns
]
(
for
[
column
columns
:let
[
fk-target
(
:fk-target-field-id
column
)]
:when
(
and
(
integer?
fk-target
)
(
lib.types.isa/foreign-key?
column
))]
{
:type
:field,
:id
fk-target
}))
(
defn-
query-dependents
[
metadata-providerable
query-or-join
]
(
let
[
base-stage
(
first
(
:stages
query-or-join
))
...
...
@@ -130,17 +138,16 @@
;; cf. frontend/src/metabase-lib/Question.ts and frontend/src/metabase-lib/queries/StructuredQuery.ts
(
when-let
[
card-id
(
:source-card
base-stage
)]
(
let
[
card-metadata
(
lib.metadata/card
metadata-providerable
card-id
)]
(
cond->
(
for
[
column
(
:result-metadata
card-metadata
)
:let
[
column
(
u/normalize-map
column
)
fk-target
(
:fk-target-field-id
column
)]
:when
(
and
(
integer?
fk-target
)
(
lib.types.isa/foreign-key?
column
))]
{
:type
:field,
:id
fk-target
})
;; the FE code mentions this, but #36974 doesn't
#
_
#
_
:always
(
conj
{
:type
:question,
:id
card-id
})
(
:dataset
card-metadata
)
(
conj
{
:type
:table,
:id
(
str
"card__"
card-id
)}))))
(
->>
(
:result-metadata
card-metadata
)
(
map
u/normalize-map
)
foreign-key-items
;; the FE code mentions this, but #36974 doesn't
#
_
(
cons
{
:type
:question,
:id
card-id
})
(
cons
{
:type
:table,
:id
(
str
"card__"
card-id
)}))))
(
when-let
[
table-id
(
:source-table
base-stage
)]
[{
:type
:table,
:id
table-id
}])
(
->>
(
lib.metadata/fields
metadata-providerable
table-id
)
foreign-key-items
(
cons
{
:type
:table,
:id
table-id
})))
(
for
[
stage
(
:stages
query-or-join
)
join
(
:joins
stage
)
dependent
(
query-dependents
metadata-providerable
join
)]
...
...
This diff is collapsed.
Click to expand it.
test/metabase/lib/fe_util_test.cljc
+
6
−
2
View file @
3bc463df
...
...
@@ -152,7 +152,8 @@
(
testing
"simple query"
(
are
[
query
]
(
=?
[{
:type
:database,
:id
(
meta/id
)}
{
:type
:schema,
:id
(
meta/id
)}
{
:type
:table,
:id
(
meta/id
:venues
)}]
{
:type
:table,
:id
(
meta/id
:venues
)}
{
:type
:field,
:id
(
meta/id
:categories
:id
)}]
(
lib/dependent-metadata
query
))
lib.tu/venues-query
(
lib/append-stage
lib.tu/venues-query
)))
...
...
@@ -160,19 +161,22 @@
(
are
[
query
]
(
=?
[{
:type
:database,
:id
(
meta/id
)}
{
:type
:schema,
:id
(
meta/id
)}
{
:type
:table,
:id
(
meta/id
:venues
)}
{
:type
:field,
:id
(
meta/id
:categories
:id
)}
{
:type
:table,
:id
(
meta/id
:categories
)}]
(
lib/dependent-metadata
query
))
lib.tu/query-with-join
(
lib/append-stage
lib.tu/query-with-join
)))
(
testing
"source card based query"
(
are
[
query
]
(
=?
[{
:type
:database,
:id
(
meta/id
)}
{
:type
:schema,
:id
(
meta/id
)}]
{
:type
:schema,
:id
(
meta/id
)}
{
:type
:table,
:id
"card__1"
}]
(
lib/dependent-metadata
query
))
lib.tu/query-with-source-card
(
lib/append-stage
lib.tu/query-with-source-card
)))
(
testing
"source card based query with result metadata"
(
are
[
query
]
(
=?
[{
:type
:database,
:id
(
meta/id
)}
{
:type
:schema,
:id
(
meta/id
)}
{
:type
:table,
:id
"card__1"
}
{
:type
:field,
:id
(
meta/id
:users
:id
)}]
(
lib/dependent-metadata
query
))
lib.tu/query-with-source-card-with-result-metadata
...
...
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