mirror of
https://github.com/logseq/logseq.git
synced 2026-05-25 21:24:21 +00:00
fix: add validation for property types and :schema attributes
Part of LOG-2953. We shouldn't persist unusuable property type configurations as shown by this bug. By enumerating what schema attributes are allowed for each type, we can prevent future bugs like this. When changing between property types, this also cleans up :classes, :position and :values that were accidentally hanging around for certain types. Also modify test since we don't allow users to use a :default property with :cardinality
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
NOTE: This script is also used in CI to confirm graph creation works"
|
||||
(:require [logseq.tasks.db-graph.create-graph :as create-graph]
|
||||
[logseq.db.sqlite.util :as sqlite-util]
|
||||
[logseq.db.frontend.property.type :as db-property-type]
|
||||
[clojure.string :as string]
|
||||
[datascript.core :as d]
|
||||
["path" :as node-path]
|
||||
@@ -70,7 +71,7 @@
|
||||
:properties
|
||||
(->> [:default :url :checkbox :number :page :date]
|
||||
(mapcat #(cond-> [[% {:block/schema {:type %}}]]
|
||||
(not (#{:checkbox :default} %))
|
||||
(db-property-type/property-type-allows-schema-attribute? % :cardinality)
|
||||
(conj [(keyword (str (name %) "-many")) {:block/schema {:type % :cardinality :many}}])))
|
||||
(into {}))}))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user