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
Required belongs_to associations aren't being validated #665
Comments
You could possibly add a validation to check the presence of |
@jkowens but we can do one single query to query all the records like my second example. It basically counts how many categories there are in all posts and makes one query to count to check how many of them really exists in the database. |
Now that I'm thinking about it, I seem to recall that AR-Import does try to automatically validate the presence of the foreign key of the I would expect this to raise an error:
Can you confirm that? As regards your example code, and the details about not validating the presence of |
Sorry, misreport on that one, using nil it does validate but using inexistent ids doesn't. |
Fixed in original report. |
Contrived example:
I'm workarounding this with a safety check:
Not sure if the issue is by design or even if we should deal with that but Rails does, it does check if the record in fact exists in the foreign table.
We might be concerned about retrieving all foreign records due to memory usage?
Maybe we can do it in another way for the
activerecord-import
like this (pseudo-code):The text was updated successfully, but these errors were encountered: