Skip to content
Snippets Groups Projects
Commit 09eef767 authored by Simon Belak's avatar Simon Belak
Browse files

Revert "Don't overwrite previously infered special types"

This reverts commit 11de3080.
parent 0d491c29
No related branches found
No related tags found
No related merge requests found
......@@ -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))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment