cognitect-labs / vase

Data driven microservices
Eclipse Public License 1.0
373 stars 42 forks source link

Cannot transact false values from payload. #81

Closed austinhaas closed 5 years ago

austinhaas commented 6 years ago

False values are removed from the payload before transacting. False values should be allowed and transacted into the database.

I believe the problem is here: https://github.com/cognitect-labs/vase/blob/bf96190bba7a7cc5efd92ea6f60503f0dc7800db/src/com/cognitect/vase/actions.clj#L399

This line should be changed from #(into {} (filter second (select-keys % ~(vec properties)))) to #(into {} (remove (comp nil? second) (select-keys % ~(vec properties))))

Or, just #(select-keys % ~(vec properties))

The result of select-keys doesn't include keys not found in the map, and if nil is actually a value that the user supplied, then this function shouldn't silently remove it.

mtnygard commented 6 years ago

We should preserve false for sure. But Datomic prohibits nil values in a transaction.

austinhaas commented 6 years ago

I think it'd be better to let Datomic complain about the nil (assuming it throws an exception), rather than silently dropping a user-supplied value.

ddeaguiar commented 5 years ago

I think false should be preserved as well. Perhaps we log that nil values are not allowed but maintain their removal before passing to Datomic.

ddeaguiar commented 5 years ago

Addressed in 5bd7e9b.