ruby/psych

Coord y is being rendered as 'y' but x is still x

Opened this issue · 1 comments

I have a rails model with coords, and when dumped to yml the y is rendered incorrectly.

For example,

>> puts Coord.new(x: 13, y: 12).attributes.to_yaml
---
id:
x: 13
"y": 12

instead of the expected

>> puts Coord.new(x: 13, y: 12).attributes.to_yaml
---
id:
x: 13
y: 12

This comes about because of this change ...
6a1c306

I have commented out those lines and I get the expected coord rendered.
I'm not sure what the solution is because I know that change was added to appease yes/no boolean guff but unfortunately y is a known coordinate also 🤷

tisba commented

That commit was the fix for #443.

Can you show, what the result of #attributes is that get's #to_yaml called on?

I'm assuming something like this (which is the correct behaviour IMO):

002 > puts({"x" => "1", "y" => "2"}.to_yaml)
---
x: '1'                                       
"y": '2'                                     
 => nil

I'm not exactly sure what the problem is, @sramsden. Unless you want the key to be interpreted as true (one of the unfortunate YAML spec attributes), then "y": 12 is "y" as a string key.