-
Notifications
You must be signed in to change notification settings - Fork 77
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
jsonb diff integration issue #30
Conversation
spec/integrations/triggers_spec.rb
Outdated
expect(diff["meta"]["old"].class).to eq diff["meta"]["new"].class | ||
expect(diff["meta"]).to eq expected_diff_meta | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/BlockAlignment: end at 74, 4 is not aligned with describe "diff" do at 61, 5.
spec/integrations/triggers_spec.rb
Outdated
diff = post.reload.log_data.diff_from version: (post.reload.log_version-1) | ||
expected_diff_meta = { | ||
"old"=>{"tags"=>["some", "tag"]}, | ||
"new"=>{"tags" => ["other"]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/SpaceAroundOperators: Surrounding space missing for operator =>.
Style/SpaceInsideHashLiteralBraces: Space inside { missing.
Style/SpaceInsideHashLiteralBraces: Space inside } missing.
spec/integrations/triggers_spec.rb
Outdated
post.update!(meta:{tags:['other']}) | ||
diff = post.reload.log_data.diff_from version: (post.reload.log_version-1) | ||
expected_diff_meta = { | ||
"old"=>{"tags"=>["some", "tag"]}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/IndentHash: Use 2 spaces for indentation in a hash, relative to the start of the line where the left curly brace is.
Style/SpaceAroundOperators: Surrounding space missing for operator =>.
Style/SpaceInsideHashLiteralBraces: Space inside { missing.
Style/WordArray: Use %w or %W for an array of words.
Style/SpaceInsideHashLiteralBraces: Space inside } missing.
spec/integrations/triggers_spec.rb
Outdated
|
||
it "generates the correct diff", :aggregate_failures do | ||
post.update!(meta:{tags:['other']}) | ||
diff = post.reload.log_data.diff_from version: (post.reload.log_version-1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/SpaceAroundOperators: Surrounding space missing for operator -.
spec/integrations/triggers_spec.rb
Outdated
let(:post) { Post.create!(params).reload } | ||
|
||
it "generates the correct diff", :aggregate_failures do | ||
post.update!(meta:{tags:['other']}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/SpaceAfterColon: Space missing after colon.
Style/SpaceInsideHashLiteralBraces: Space inside { missing.
Style/SpaceInsideHashLiteralBraces: Space inside } missing.
spec/integrations/triggers_spec.rb
Outdated
@@ -58,6 +58,21 @@ | |||
end | |||
end | |||
|
|||
describe "diff" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/IndentationConsistency: Inconsistent indentation detected.
spec/integrations/triggers_spec.rb
Outdated
@@ -30,7 +30,7 @@ | |||
|
|||
after(:all) { @old_post.destroy! } | |||
|
|||
let(:params) { { title: 'Triggers', rating: 10, active: false } } | |||
let(:params) { { title: 'Triggers', rating: 10, active: false, meta: { tags: ['some','tag'] } } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/WordArray: Use %w or %W for an array of words.
Style/SpaceAfterComma: Space missing after comma.
Thanks for the report and the test! That's gonna be a little bit tricky to handle such cases, but we'll try |
I think it was broken, when you started use hstore_to_jsonb_loose( hstore(NEW.) - hstore(OLD.() ) instead of jsonb_minus e73587d#diff-fd3849333d83fe38f43eb6bde43836e6 |
Yep, mainly performance, Using something different from I think, the better solution here is to provide different diff functions and allow users to choose the right on for them. |
@palkan what is the reason to provide several options if one of the options is partially broken? |
Frankly speaking, all of the options are partially broken: none of the above considers the column/model information. What if we want to use non-JSON serialization? The same problem. And it can't be solved DB-side. Thus we have to use ActiveRecord Attributes API ( |
Merged by #52 |
Release as 0.6.0 |
when calculating the diff of a model version that has a jsonb column data is incorrectly deserialized
added failing tests, happy to help but not sure where to start