Fork me on GitHub
#datascript
<
2016-07-30
>
jjunior13003:07:35

can someone help me figure out this error message?

#object[Error Error: Cannot compare {"s" -2, "m" 1} to {"s" -1, "kg" 1, "m" 1}]
Error: Cannot compare {"s" -2, "m" 1} to {"s" -1, "kg" 1, "m" 1}
I suspect DataScript can't compare maps? must I represent a dimension's formula with another data structure?

jjunior13003:07:57

then I run it

jjunior13003:07:12

and the result is 1 entity added:

{:datoms [[1 :dimension {"s" -2, "m" 1} 536870913] 
          [1 :dimension/name "acceleration" 536870913]]}
and an error message:
#object[Error Error: Cannot compare {"s" -2, "m" 1} to {"s" -1, "kg" 1, "m" 1}]
Error: Cannot compare {"s" -2, "m" 1} to {"s" -1, "kg" 1, "m" 1}
but when I run it without the schema I get no errors and all entities are added.

Niki05:07:36

Maps are not comparable in clojure

Niki05:07:05

Datascript only tries to compare values if they participate on index

Niki05:07:39

If you don't have db/index true, db/unique on the attribute

Niki05:07:01

Or db.cardinality/many

Niki05:07:30

You should be safe storing maps directly

jjunior13005:07:15

oh ok. now I need to find a way to find the dimension's entity id that matches the unit's dimension formula.

Niki06:07:42

If you find yourself needing something like this, better use separate attribute