Transacting norms to database in a deterministic order
Hi,
We recently ran into an issue caused by two things happening at the same time: 1. forgetting to add :requires, 2. (keys norm-map) returning keys in a non-deterministic order.
What happened was that we added a new norm to our schema file, and suddenly tests in CI started to break. The reason for this was a much earlier norm without :requires and the fact that when we added a new key to the norm-map it seemed to trigger Clojure to change the internal order of the map, thus (keys norm-map) returned the keys in an order that provoked this issue.
(Just to note that this isn't really a bug in conformity, but our mistake of forgetting to add the :requires)
To prevent this happening in the future, I was planning to avoid the non-deterministic behavior by using the 3-arity version of the ensure-conforms and pass a sequence of norm-names, assuming that the norms are then transacted deterministically in the order or norm-names seq. However, the docstring of the norm-names doesn't mention anything about the order:
norm-names (optional) A collection of names of norms to conform to.
Will use keys of norm-map if not provided.
Question: By reading the code I can see that norms are reduced in the order of norm-names, but is this a behaviour I can rely on?
Change request: ☝️ If yes, would it be ok to add that in the docstring?
@rap1ds
Sorry response took awhile! I think transacting in order is a necessary feature and adding the docstring would be appreciated.