aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/coders/json_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Fix bug in JSON deserialization when column default is an empty stringJohannes Opper2016-02-221-0/+15
When `ActiveRecord::Coders::JSON` serialization is used and the default of the column returns `''` it raises the following error: ``` JSON::ParserError: A JSON text must at least contain two octets! ``` If MySQL is running in non-strict mode, it returns an empty string as column default for a text column: ```ruby def extract_default if blob_or_text_column? @default = null || strict ? nil : '' end end ``` Since `''` is invalid JSON, there shouldn't be an attempt to parse it, it should be treated like nil. ActiveRecord::Coders::JSON should behave consistently for all possible non-user-set column default values.