|
370 | 370 |
|
371 | 371 | (defn- infer-property-schema-and-get-property-change
|
372 | 372 | "Infers a property's schema from the given _user_ property value and adds new ones to
|
373 |
| - the property-schemas atom. If a property's :type changes, returns a map of |
| 373 | + the property-schemas atom. If a property's :logseq.property/type changes, returns a map of |
374 | 374 | the schema attribute changed and how it changed e.g. `{:type {:from :default :to :url}}`"
|
375 | 375 | [db prop-val prop prop-val-text refs {:keys [property-schemas all-idents]} macros]
|
376 | 376 | ;; Explicitly fail an unexpected case rather than cause silent downstream failures
|
|
390 | 390 | :else
|
391 | 391 | (db-property-type/infer-property-type-from-value
|
392 | 392 | (macro-util/expand-value-if-macro prop-val macros)))
|
393 |
| - prev-type (get-in @property-schemas [prop :type])] |
| 393 | + prev-type (get-in @property-schemas [prop :logseq.property/type])] |
394 | 394 | ;; Create new property
|
395 | 395 | (when-not (get @property-schemas prop)
|
396 | 396 | (create-property-ident db all-idents prop)
|
397 |
| - (let [schema (cond-> {:type prop-type} |
| 397 | + (let [schema (cond-> {:logseq.property/type prop-type} |
398 | 398 | (#{:node :date} prop-type)
|
399 | 399 | ;; Assume :many for now as detecting that detecting property values across files are consistent
|
400 | 400 | ;; isn't possible yet
|
401 |
| - (assoc :cardinality :many))] |
| 401 | + (assoc :db/cardinality :many))] |
402 | 402 | (swap! property-schemas assoc prop schema)))
|
403 | 403 | (when (and prev-type (not= prev-type prop-type))
|
404 | 404 | {:type {:from prev-type :to prop-type}})))
|
|
555 | 555 | ;; Change to :node as dates can be pages but pages can't be dates
|
556 | 556 | (= {:from :date :to :node} type-change)
|
557 | 557 | (do
|
558 |
| - (swap! property-schemas assoc-in [prop :type] :node) |
| 558 | + (swap! property-schemas assoc-in [prop :logseq.property/type] :node) |
559 | 559 | (update-page-or-date-values page-names-to-uuids val))
|
560 | 560 |
|
561 | 561 | ;; Unlike the other property changes, this one changes all the previous values of a property
|
|
568 | 568 | (swap! ignored-properties conj {:property prop :value val :schema (get property-changes prop)})
|
569 | 569 | nil)
|
570 | 570 | (do
|
571 |
| - (swap! upstream-properties assoc prop {:schema {:type :default} |
| 571 | + (swap! upstream-properties assoc prop {:schema {:logseq.property/type :default} |
572 | 572 | :from-type (:from type-change)})
|
573 |
| - (swap! property-schemas assoc prop {:type :default}) |
| 573 | + (swap! property-schemas assoc prop {:logseq.property/type :default}) |
574 | 574 | (get properties-text-values prop)))
|
575 | 575 |
|
576 | 576 | :else
|
|
590 | 590 | [prop val'])
|
591 | 591 | [prop
|
592 | 592 | (if (set? val)
|
593 |
| - (if (= :default (:type (get @property-schemas prop))) |
| 593 | + (if (= :default (:logseq.property/type (get @property-schemas prop))) |
594 | 594 | (get properties-text-values prop)
|
595 | 595 | (update-page-or-date-values page-names-to-uuids val))
|
596 | 596 | val)])))
|
|
609 | 609 | (let [property-map {:db/ident k
|
610 | 610 | :logseq.property/type built-in-type}]
|
611 | 611 | [property-map v]))
|
612 |
| - (when (db-property-type/value-ref-property-types (:type (get-schema-fn k))) |
613 |
| - (let [schema (get-schema-fn k) |
614 |
| - property-map (merge |
| 612 | + (when (db-property-type/value-ref-property-types (:logseq.property/type (get-schema-fn k))) |
| 613 | + (let [property-map (merge |
615 | 614 | {:db/ident (get-ident all-idents k)
|
616 | 615 | :original-property-id k}
|
617 |
| - (sqlite-util/schema->qualified-property-keyword schema))] |
| 616 | + (get-schema-fn k))] |
618 | 617 | [property-map v])))))
|
619 | 618 | (db-property-build/build-property-values-tx-m new-block)))
|
620 | 619 |
|
|
1095 | 1094 | (fn [[prop {:keys [schema from-type]}]]
|
1096 | 1095 | (let [prop-ident (get-ident all-idents prop)
|
1097 | 1096 | upstream-tx
|
1098 |
| - (when (= :default (:type schema)) |
| 1097 | + (when (= :default (:logseq.property/type schema)) |
1099 | 1098 | (build-upstream-properties-tx-for-default db prop prop-ident from-type block-properties-text-values))
|
1100 |
| - property-pages-tx [(merge |
1101 |
| - {:db/ident prop-ident} |
1102 |
| - (sqlite-util/schema->qualified-property-keyword schema))]] |
| 1099 | + property-pages-tx [(merge {:db/ident prop-ident} schema)]] |
1103 | 1100 | ;; If we handle cardinality changes we would need to return these separately
|
1104 | 1101 | ;; as property-pages would need to be transacted separately
|
1105 | 1102 | (concat property-pages-tx upstream-tx)))
|
|
1117 | 1114 | :ignored-properties (atom [])
|
1118 | 1115 | ;; Vec of maps with keys :path and :reason
|
1119 | 1116 | :ignored-files (atom [])
|
1120 |
| - ;; Map of property names (keyword) and their current schemas (map). |
| 1117 | + ;; Map of property names (keyword) and their current schemas (map of qualified properties). |
1121 | 1118 | ;; Used for adding schemas to properties and detecting changes across a property's usage
|
1122 | 1119 | :property-schemas (atom {})
|
1123 | 1120 | ;; Map of property or class names (keyword) to db-ident keywords
|
|
0 commit comments