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

Support relations #2

Closed
jalberto opened this issue Sep 4, 2009 · 8 comments
Closed

Support relations #2

jalberto opened this issue Sep 4, 2009 · 8 comments

Comments

@jalberto
Copy link

jalberto commented Sep 4, 2009

Will be nice if paperclip support model relations

@airblade
Copy link
Collaborator

airblade commented Sep 4, 2009

I agree. It's non-trivial though. If you have any suggestions, I'd like to hear them.

@jalberto
Copy link
Author

jalberto commented Sep 4, 2009

has_versioning(http://github.com/kkurach/has_versioning/tree/master) support it, maybe it can inspire you :)

@airblade
Copy link
Collaborator

airblade commented Sep 4, 2009

Thanks for the reference. I'll have a look.

@KevinTriplett
Copy link

+1 for model relations and I would be happy to collaborate on this feature.

@airblade
Copy link
Collaborator

airblade commented Sep 4, 2009

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.

@airblade
Copy link
Collaborator

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.

@KevinTriplett
Copy link

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.

@airblade
Copy link
Collaborator

That's certainly how I'm doing it at the moment in my apps. It's not ideal but it gets by for now...

sergey-alekseev added a commit to sergey-alekseev/paper_trail that referenced this issue Sep 29, 2017
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
```
This issue was closed.
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

3 participants