radar/paranoia — pull request #171 by srecnig (2014-10-06 12:35:16+00:00)
Title: Restoring has_one with recursive: true leads to ActiveRecord::StatementInvalid

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.

SELECT "authors".* FROM "authors" WHERE ("authors"."deleted_at" IS NOT NULL) AND (user_id) ORDER BY "authors"."id" ASC LIMIT 1

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 invalid ``AND(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?