Skip to content
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

YAML error when having dates as keys (upgrading to v4) #1930

Closed
qqube opened this issue Jun 6, 2016 · 11 comments
Closed

YAML error when having dates as keys (upgrading to v4) #1930

qqube opened this issue Jun 6, 2016 · 11 comments

Comments

@qqube
Copy link

qqube commented Jun 6, 2016

This is may not be a bug, but it is at least an undocumented breaking change introduced in v4.

In my data dir I have YAML files that contain dates as key, for example:

2016-03-25:
  tag: seminar
  content: blah

With v3, everything were fine, but with v4, I got the following error:

YAML Exception parsing /home/.../data/news.yaml: undefined method `to_sym' for #<Date: 2016-03-25 ((2457473j,0s,0n),+0s,2299161j)>
Did you mean?  to_s

How can I revert to the previous behavior? (Of course, I can wrap all my dates into quotes, but I would appreciate to avoid that.)

@tdreyno
Copy link
Member

tdreyno commented Jun 6, 2016

You're using a date as a key? Didn't realize YAML would parse that into a date. Try wrapping it in quotes?

@qqube
Copy link
Author

qqube commented Jun 6, 2016

Yes, I don't know it is the best idea I've ever had, but I do. Of course, if I enclose it into quotes, but then it is not a date anymore, but a string.

@tdreyno
Copy link
Member

tdreyno commented Jun 7, 2016

Oh, you want it to act as a date?

@qqube
Copy link
Author

qqube commented Jun 7, 2016

Yes I do. In v3, that used to work. I am just trying to find out if there is a way to make it work again or if I have to modify all my YAML files.

@tdreyno
Copy link
Member

tdreyno commented Jun 7, 2016

I think you'll have to modify the YAML files. There's code to do stuff like data.news.stuff[0].tag and it relies on each step being something that can chain like that (so it has to work with to_sym).

Simplest thing is probably to stringify the key, then add an actual Data type row in it's sub-content.

@ryanhageman
Copy link

Is this still an issue?

@leighmcculloch
Copy link
Contributor

This is an issue for me too. I just tried updating an app to v4.2.1 and have experienced the same issue with integer keys, reported here #2238. Keys in YAML can be any type, they aren't bound to be strings. Integer keys definitely worked in v3 and that behavior has appeared to change in v4.

@tdreyno
Copy link
Member

tdreyno commented Jan 7, 2019

I’ll add this to the test suite

@tdreyno
Copy link
Member

tdreyno commented Jan 8, 2019

Fixed here: 1dc1611

@leighmcculloch
Copy link
Contributor

I ran the build against 4.2-stable at that commit, and 💥 it works perfectly with integer keys. Thanks!!!

@tdreyno
Copy link
Member

tdreyno commented Jan 9, 2019

Great, waiting for an upstream release of Bundler to put out the point release officially.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants