Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transacting norms to database in a deterministic order #52

Open
rap1ds opened this issue Oct 14, 2021 · 1 comment
Open

Transacting norms to database in a deterministic order #52

rap1ds opened this issue Oct 14, 2021 · 1 comment

Comments

@rap1ds
Copy link

rap1ds commented Oct 14, 2021

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?

@iku000888
Copy link
Collaborator

@rap1ds

Sorry response took awhile!
I think transacting in order is a necessary feature and adding the docstring would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants