hyperfiddle-2020 icon indicating copy to clipboard operation
hyperfiddle-2020 copied to clipboard

Value 190 is not a valid :float for attribute :record/weight

Open dustingetz opened this issue 7 years ago • 15 comments

dustingetz avatar Apr 10 '18 22:04 dustingetz

Can be fixed generally by spec coercion i think!

dustingetz avatar Nov 15 '18 18:11 dustingetz

All d/with calls need to be coerced against Datomic schema

dustingetz avatar Jun 11 '19 15:06 dustingetz

All :in clauses also need a spec provided from userland (routes)

dustingetz avatar Jun 11 '19 15:06 dustingetz

This is line of fire for a consulting lead who asked me to replicate a trivial spreadsheet, i had to add .01 to make these parse as floats:

image

dustingetz avatar Sep 17 '19 18:09 dustingetz

This can be done at the last second (d/with db-with {:tx-data (coerce-tx tx schema)})

But the client has the schema, cant it send up correct values in the first place?

dustingetz avatar Oct 12 '19 00:10 dustingetz

image

dustingetz avatar Oct 12 '19 00:10 dustingetz

No, Javascript can't tell the difference i forgot. Internal representation of number and float is the same. Can it happen at the point of serializing to transit? This theoretically could happen but Transit would need to deeply understand [:db/add e a v] and know that v is typed by a

dustingetz avatar Oct 12 '19 00:10 dustingetz

https://ask.clojure.org/index.php/8713/transit-schema

dustingetz avatar Oct 12 '19 15:10 dustingetz

https://github.com/cognitect/transit-cljs/issues/54

dustingetz avatar Oct 12 '19 17:10 dustingetz

https://github.com/alexanderkiel/spec-coerce/issues/7

dustingetz avatar Oct 12 '19 18:10 dustingetz

 [:db/add "hyperfiddle.tempid-525511487" :db/ident :dustingetz/weight]
 [:db/add "hyperfiddle.tempid-525511487" :db/cardinality :db.cardinality/one]
 [:db/add "hyperfiddle.tempid-525511487" :db/valueType :db.type/float]

dustingetz avatar Oct 12 '19 19:10 dustingetz

Ok this is fucked ... to coerce the tx accounting for expected valueTypes ... you need to know the schema... which means a schema query already happened earlier in the request... but what if this is the request for the schema (bootstrapping the request). You need a pre-tx value of the schema

dustingetz avatar Oct 12 '19 23:10 dustingetz

image

dustingetz avatar Oct 12 '19 23:10 dustingetz

Consider the following user-stage + ide-stage image

Each side's first query is a schema query and that schema query has the stage applied and that stage needs normalizing despite not having the schema yet

Fix 1 is to throw a hardcoded d/q in there Fix 2 is to somehow get the client to send the right values up in the first place

dustingetz avatar Oct 13 '19 00:10 dustingetz

Current thinking: Hydrate the schemas twice, first time without the stage, shove them into partition, then run this code as usual image

dustingetz avatar Oct 13 '19 00:10 dustingetz