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

Creating users with duplicate email is not erroring #57

Open
RobStallion opened this issue Apr 17, 2019 · 2 comments
Open

Creating users with duplicate email is not erroring #57

RobStallion opened this issue Apr 17, 2019 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@RobStallion
Copy link
Member

I am currently using alog in another project where two tables are being updated at the same time.

The venue table has a many to many association with the users table. When a user of the site creates a new venue they can also create a new user at the same time.

However, for some reason the user changeset function is not working as expected here. It is allowing multiple users with the same email address to be created.

This does not happen when you try to create a user on their own (e.g. Call the User.insert function directly with a user changeset)

@RobStallion RobStallion added bug Something isn't working help wanted Extra attention is needed labels Apr 17, 2019
@RobStallion RobStallion self-assigned this Apr 17, 2019
@RobStallion
Copy link
Member Author

It appears that the reason for the error is because the user changeset function does not return an error when there is a duplicate email hash. That step looks like it is being done in alog.

Alog must have a function for checking unique constraints, but this step must be missed when the table is an association.

@RobStallion RobStallion removed the help wanted Extra attention is needed label Apr 17, 2019
@RobStallion
Copy link
Member Author

As there cannot be a unique index in alog (as many rows can relate to one user for example) it looks like alog is doing a version of this logic here.

I don't fully understand this function at the moment but it appears that it gets a list of constraints from changeset and reduces them, returning a changeset with errors added as needed. However it does not appear to work for associations.

I will take a deeper look at this but from what I have seen so far it appears that associations in changesets, are just a list of changesets themselves (at least in the case of a many to many association). This should mean that this function can be called recursively on the nested list of changeset.

I am not sure how the errors in nested changeset will effect the top level changeset at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant