Problem
When pulling from a sequence of maps, lasagna-pull requires all map keys to be specified up front. For example:
((pull/query ['?]) [{:a 1} {:a 2 :b 1}]) ;=> Exception: Wrong pattern
((pull/query [{:a '?}]) [{:a 1} {:a 2 :b 1}]) ;=> [{:a 1} {:a 2}]
Impact
It is difficult to work with lists of entities that may not follow fixed schemas, such as when working with Datomic or re-frame.
Probable cause
schema/patten-schema-of does not handle [:sequential :map] correctly. For example:
(def data-schema
[:vector :map])
(def pattern-schema
(schema/pattern-schema-of data-schema))
pattern-schema
;; => [:cat {:sg.flybot.pullable.schema/pattern? true}
;; => :map
;; => [:? [:fn #function[lvar?]]]
;; => [:? [:alt [:cat [:= :seq] [:vector {:min 1, :max 2} :int]]]]]
(malli.core/validate pattern-schema ['?]) ;=> false
(malli.core/validate pattern-schema [{} '?]) ;=> true
Suggestion
Problem
When pulling from a sequence of maps,
lasagna-pullrequires all map keys to be specified up front. For example:Impact
It is difficult to work with lists of entities that may not follow fixed schemas, such as when working with Datomic or re-frame.
Probable cause
schema/patten-schema-ofdoes not handle[:sequential :map]correctly. For example:Suggestion
Allow using
['?]to pull whole elements (such as entire maps) from a sequence. For example: