-
Notifications
You must be signed in to change notification settings - Fork 895
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
Support relations #2
Comments
I agree. It's non-trivial though. If you have any suggestions, I'd like to hear them. |
has_versioning(http://github.com/kkurach/has_versioning/tree/master) support it, maybe it can inspire you :) |
Thanks for the reference. I'll have a look. |
+1 for model relations and I would be happy to collaborate on this feature. |
That's an interesting blog post you wrote, Kevin, on auditing and versioning. Nice to see PaperTrail making the cut ;) I'll have a think about model relations and give you a shout if need be. |
If anyone wants to send in patches, that would be great. I can't figure out how to do this in the limited time I have available. |
I may come up with something eventually but I'm in the same boat. :) it may be best to handle this on the application domain since the business rules dictate which associations are important and the conditions under which they should be versioned. |
That's certainly how I'm doing it at the moment in my apps. It's not ideal but it gets by for now... |
History --- [The first problem mention](paper-trail-gem@1ad7838). [The major issue](paper-trail-gem#803) with relevant discussions. Details --- I see the problem only with one specific case – when the method is `where_object_changes` and the serializer is YAML. Which is a default configuration. I see there are 6 types of queries with a numeric value for `where_object_changes` and `where_object` (grabbed from `version_spec.rb`): ``` SELECT "versions".* FROM "versions" WHERE "versions"."item_id" = 1 AND "versions"."item_type" = 'Widget' AND (object_changes @> '{"an_integer":[1]}') ORDER BY "versions"."created_at" ASC, "versions"."id" ASC SELECT "versions".* FROM "versions" WHERE "versions"."item_id" = 1 AND "versions"."item_type" = 'Widget' AND ("versions"."object_changes" ILIKE '% an_integer: - 1 %' OR "versions"."object_changes" ILIKE '% an_integer: -% - 1 %') ORDER BY "versions"."created_at" ASC, "versions"."id" ASC SELECT "versions".* FROM "versions" WHERE "versions"."item_id" = 1 AND "versions"."item_type" = 'Widget' AND (((object_changes->>'an_integer' ILIKE '[1,%') OR (object_changes->>'an_integer' ILIKE '[%,1]%'))) ORDER BY "versions"."created_at" ASC, "versions"."id" ASC SELECT "versions".* FROM "versions" WHERE (object @> '{"an_integer":1}') SELECT "versions".* FROM "versions" WHERE (object->>'an_integer' = '1') SELECT "versions".* FROM "versions" WHERE ("versions"."object" ILIKE '% an_integer: 1 %') ``` The only problematic one is `paper-trail-gem#2`. It incorrectly matches `object_changes` like ``` --- name: - - Kimberli an_integer: - - 0 created_at: - - 2017-09-28 18:30:13.369889000 Z updated_at: - - 2017-09-28 18:30:13.369889000 Z id: - - 1 --- name: - foobar - Hayes an_integer: - 77 - 1 updated_at: - 2017-09-28 18:30:13.383966000 Z - 2017-09-28 18:30:13.395539000 Z ```
Will be nice if paperclip support model relations
The text was updated successfully, but these errors were encountered: