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
09eef767
Commit
09eef767
authored
6 years ago
by
Simon Belak
Browse files
Options
Downloads
Patches
Plain Diff
Revert "Don't overwrite previously infered special types"
This reverts commit
11de3080
.
parent
0d491c29
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/sync/analyze/classifiers/name.clj
+9
-12
9 additions, 12 deletions
src/metabase/sync/analyze/classifiers/name.clj
with
9 additions
and
12 deletions
src/metabase/sync/analyze/classifiers/name.clj
+
9
−
12
View file @
09eef767
...
...
@@ -107,22 +107,19 @@
(
s/defn
^
:private
special-type-for-name-and-base-type
:-
(
s/maybe
su/FieldType
)
"If field `:name` and `:base_type` matches a known pattern, return the `special_type` we should assign to it."
[
field
:-
i/FieldInstance
]
(
cond
(
=
"id"
(
str/lower-case
(
:name
field
)))
:type/PK
(
nil?
(
:special_type
field
))
; don't overwrite previously infered types
(
some
(
fn
[[
name-pattern
valid-base-types
special-type
]]
(
when
(
and
(
some
(
partial
isa?
(
:base_type
field
))
valid-base-types
)
(
re-find
name-pattern
(
str/lower-case
(
:name
field
))))
special-type
))
pattern+base-types+special-type
)))
"If `name` and `base-type` matches a known pattern, return the `special_type` we should assign to it."
[
field-name
:-
su/NonBlankString,
base-type
:-
su/FieldType
]
(
or
(
when
(
=
"id"
(
str/lower-case
field-name
))
:type/PK
)
(
some
(
fn
[[
name-pattern
valid-base-types
special-type
]]
(
when
(
and
(
some
(
partial
isa?
base-type
)
valid-base-types
)
(
re-find
name-pattern
(
str/lower-case
field-name
)))
special-type
))
pattern+base-types+special-type
)))
(
s/defn
infer-special-type
:-
(
s/maybe
i/FieldInstance
)
"Classifer that infers the special type of a FIELD based on its name and base type."
[
field
:-
i/FieldInstance,
_
:-
(
s/maybe
i/Fingerprint
)]
(
when-let
[
inferred-special-type
(
special-type-for-name-and-base-type
field
)]
(
when-let
[
inferred-special-type
(
special-type-for-name-and-base-type
(
:name
field
)
(
:base_type
field
)
)]
(
log/debug
(
format
"Based on the name of %s, we're giving it a special type of %s."
(
sync-util/name-for-logging
field
)
inferred-special-type
))
...
...
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