1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

8 commits

Author SHA1 Message Date
Johannes Opper
894facb196 Fix bug in JSON deserialization when column default is an empty string
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.
2016-02-22 17:59:51 +01:00
Mike Mangino
1bf6b53aa4 Remove all error masking when decoding serialized data fails? 2013-04-02 11:45:14 -04:00
Mike Mangino
a4743960a0 Raise an exception when unserialization fails due to a missing class 2013-03-28 11:19:01 -04:00
Guten
9637de6b47 ActiveRecord::Coders::YAMLColumn#dump should raise an error
closes #2737

Conflicts:

	activerecord/lib/active_record/coders/yaml_column.rb
2012-03-26 21:57:39 +02:00
Aaron Patterson
61774e0d49 please use ruby -I lib:test path/to/test.rb, or export RUBY_OPT 2011-06-06 15:47:13 -07:00
Jon Leighton
253bb6b926 Refactor Active Record test connection setup. Please see the RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases. 2011-06-04 23:47:03 +01:00
Guillermo Álvarez
351331fb34 Make serialized columns with explicit object_type return a new instance of the object instead of nil 2011-02-03 09:08:45 -08:00
Aaron Patterson
3cc2b77dc1 adding a YAML Column coder for YAML serialization to db columns 2011-02-01 14:25:46 -08:00