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

mongoose adapter: better verify user-provided linkage in relationships #152

Open
ethanresnick opened this issue Feb 18, 2018 · 0 comments
Open

Comments

@ethanresnick
Copy link
Owner

Quoting from #149 (comment)

The adapter should at least verify that the type key in the linkage matches the type for the root model of the model that the relationship points to. That is, if the relationship is specified as holding a school, the adapter should at least verify that the linkage type is "organizations". If you want to work up a failing test for that, it would be much appreciated.

Arguably, the adapter should go further and verify that there actually is a document that exists with that id and that its discriminator key indicates that it is really a school, but I think that check is lower priority/I go back and forth on whether it's worth the overhead. (That check for the actual existence of a document with the related id didn't happen before subtypes were introduced either, and would require another query for each relationship in mongo land. Checking the existence of the related resource is easier in SQL land, I imagine, as the foreign key constraint should just fail.)

This issue is just a reminder to self.

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

1 participant