Restoring has_one with recursive: true leads to ActiveRecord::StatementInvalid #171
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
i'm using paranoia with rails 4.1.5 and postgres. when trying to restore a record with a has_one association, activerecord will build an invalid query, e.g.
as far as i understand it, the reason seems to be that the where call in
restore_associated_records
is not given a hash, but rather a string and the id. activerecord interprets this as raw sql and therefore creates the invalidAND(user_id)
.changing this to a hash fixes the problem in my app and does not raise any new errors with the test suite. btw, i can reproduce the error only in my app, and not with the test suite that ships with paranoia, i think it's because sqlite does not have a problem with such a query?