Fixed paper trail inconsistent results for numeric values

There is a known issue in paper_trail that whenever we Query the
'versions.object' column it evaluates inconsistent results for numeric
values due to limitations of SQL wildcard matchers against the
serialized objects. So to fix this issue I have manually formed the where
query instead of using where_object and where_object_changes. I have
also added test for the same.
Fixes #1307
This commit is contained in:
Siddhant Bajaj 2017-04-24 15:39:39 +05:30 committed by Stella Rouzi
parent 3ae97eb889
commit 1c12200003
3 changed files with 48 additions and 7 deletions

View file

@ -50,8 +50,8 @@ module Admin
@ratings = @event.votes.includes(:user)
@difficulty_levels = @program.difficulty_levels
@versions = @event.versions |
PaperTrail::Version.where(item_type: 'Commercial').where_object(commercialable_id: @event.id, commercialable_type: 'Event') |
PaperTrail::Version.where(item_type: 'Commercial').where_object_changes(commercialable_id: @event.id, commercialable_type: 'Event') |
PaperTrail::Version.where(item_type: 'Commercial').where('object LIKE ?', "%commercialable_id: #{@event.id}\ncommercialable_type: Event%") |
PaperTrail::Version.where(item_type: 'Commercial').where('object_changes LIKE ?', "%commercialable_id:\n- \n- #{@event.id}\ncommercialable_type:\n- \n- Event%") |
PaperTrail::Version.where(item_type: 'Vote').where('object_changes LIKE ?', "%\nevent_id:\n- \n- #{@event.id}\n%") |
PaperTrail::Version.where(item_type: 'Vote').where('object LIKE ?', "%\nevent_id: #{@event.id}\n%")
end