This project is archived and is in readonly mode.
Columns marked for serialization do not serialize
-
Bryce Kerley
So it turns out that attributes_with_quotes grabs the unserialized version through the provided accessor, and then re-serializes them into the database. http://github.com/bkerley/serial... adds a test displaying this case. I'm still cooking up a fix for this.
-
Bryce Kerley
Can't do this the way I'm doing it without creating stupid workarounds for lots of tests.
-
Bryce Kerley
- Tag changed from activerecord, bug, patch, serialization, tested, yaml to activerecord, bug, patch, serialization, yaml
OK, got this most of the way fixed, except I'm failing a couple validation tests:
1) Failure: test_validate_uniqueness_scoped_to_defining_class(ValidationsTest) [./test/cases/validations_test.rb:393:in `test_validate_uniqueness_scoped_to_defining_class' ./test/cases/../../lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:67:in `__send__' ./test/cases/../../lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:67:in `run']: Saving r2. <false> is not true. 2) Failure: test_validate_uniqueness_with_scope(ValidationsTest) [./test/cases/validations_test.rb:376:in `test_validate_uniqueness_with_scope' ./test/cases/../../lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:67:in `__send__' ./test/cases/../../lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:67:in `run']: Saving r2 first time. <false> is not true.The changed code, tests, etc. are in the git repo: http://github.com/bkerley/serial...
-
Murray Steele
+1
The breakages you are seeing were already there. Even without your patch you can't validate uniqueness against serialized attributes. It's just that before a string wouldn't be saved as a yamlized string so the find would work. (E.g. with/without your patch it does select * from whatever where whatever.serialized_attribute = 'a string'; whereas what's in the DB is '---\n "a string"'.)
Either:
1. we fix the tests to not test validation of uniqueness against serialized attributes
2. we fix validates_uniqueness of to work with serialized attribtues
3. we fix finders to know about serialized attributes and co-erce values accordingly.
1 or 3 work for me.
