-
Notifications
You must be signed in to change notification settings - Fork 901
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
Deprecate where_object_changes reading YAML from a text column #997
Conversation
To clarify, I am suggesting that we raise an error when someone is storing YAML in a |
f7f243c
to
fa1185d
Compare
@jaredbeck I think applying a "solution" like #979 + #993 is better than not applying it. Ideally such cases should be fixed, but I'm not interested in a text column. FYI I fixed a failed spec example by changing let(:int) { column_datatype_override ? 1 : rand(5) + 1 } to let(:int) { column_datatype_override ? 1 : rand(5) + 2 } Initially I didn't take into account |
OK, raising an error is a breaking change, so we should start with a deprecation warning , just like we did in #979. If you agree, will you please add such a warning, Sergey? Thanks! |
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`): ``` .where_object_changes N1 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 N1 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 N3 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 .where_object N4 SELECT "versions".* FROM "versions" WHERE (object @> '{"an_integer":1}') N5 SELECT "versions".* FROM "versions" WHERE (object->>'an_integer' = '1') N6 SELECT "versions".* FROM "versions" WHERE ("versions"."object" ILIKE '% an_integer: 1 %') ``` The only problematic one is N2. 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 ```
fa1185d
to
8cfdc19
Compare
@jaredbeck I added a deprecation warning. Let me know if you think commits should be squashed. |
Looks perfect! Thanks Sergey. |
We'll wait a few months after this deprecation warning is released to give people a chance to discuss the issue here. Then, if no concerns are raised we will replace the warning with an error. |
where_object_changes
for numeric values
History
The first problem mention.
The major issue 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
andwhere_object
(grabbed fromversion_spec.rb
):The only problematic one is
#2
. It incorrectly matchesobject_changes
like@batter @jaredbeck correct me if I'm wrong.