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
84735b55
Unverified
Commit
84735b55
authored
11 months ago
by
Cal Herries
Committed by
GitHub
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Revert "Revert updating FKs during metadata sync (#39679) (#39924)" (#40233)
parent
f2e8df68
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/sync/sync_metadata/fks.clj
+9
-3
9 additions, 3 deletions
src/metabase/sync/sync_metadata/fks.clj
test/metabase/sync/sync_metadata/fields_test.clj
+1
-2
1 addition, 2 deletions
test/metabase/sync/sync_metadata/fields_test.clj
with
10 additions
and
5 deletions
src/metabase/sync/sync_metadata/fks.clj
+
9
−
3
View file @
84735b55
...
...
@@ -51,7 +51,9 @@
;; - fk_target_field_id is NULL and the new target is not NULL
;; - fk_target_field_id is not NULL but the new target is different and not NULL
[
pk-field-id-query
:pk
]
[
:=
:f.fk_target_field_id
nil
]]
[
:or
[
:=
:f.fk_target_field_id
nil
]
[
:not=
:f.fk_target_field_id
:pk.id
]]]
:set
{
:fk_target_field_id
:pk.id
:semantic_type
"type/FK"
}}
:postgres
...
...
@@ -62,7 +64,9 @@
:semantic_type
"type/FK"
}
:where
[
:and
[
:=
:fk.id
:f.id
]
[
:=
:f.fk_target_field_id
nil
]]}
[
:or
[
:=
:f.fk_target_field_id
nil
]
[
:not=
:f.fk_target_field_id
:pk.id
]]]}
:h2
{
:update
[
:metabase_field
:f
]
:set
{
:fk_target_field_id
pk-field-id-query
...
...
@@ -70,7 +74,9 @@
:where
[
:and
[
:=
:f.id
fk-field-id-query
]
[
:not=
pk-field-id-query
nil
]
[
:=
:f.fk_target_field_id
nil
]]})]
[
:or
[
:=
:f.fk_target_field_id
nil
]
[
:not=
:f.fk_target_field_id
pk-field-id-query
]]]})]
(
sql/format
q
:dialect
(
mdb.connection/quoting-style
(
mdb.connection/db-type
)))))
(
mu/defn
^
:private
mark-fk!
...
...
This diff is collapsed.
Click to expand it.
test/metabase/sync/sync_metadata/fields_test.clj
+
1
−
2
View file @
84735b55
...
...
@@ -247,8 +247,7 @@
;; 3. add back the FK relationship but targeting continent_2
(
jdbc/execute!
db-spec
"ALTER TABLE country ADD CONSTRAINT country_continent_id_fkey FOREIGN KEY (continent_id) REFERENCES continent_2(id);"
)
(
sync/sync-database!
db
{
:scan
:schema
})
;; FIXME: The following test fails. This was fixed (metabase#39679) but regressed to solve a flakey test (metabase#39861)
#
_
(
testing
"initially country's continent_id is targeting continent_2"
(
testing
"initially country's continent_id is targeting continent_2"
(
is
(
=?
{
:fk_target_field_id
(
mt/id
:continent_2
:id
)
:semantic_type
:type/FK
}
(
get-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