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

Wrongly inserting '---' characters #17

Open
charlesdeb opened this issue Apr 30, 2011 · 5 comments
Open

Wrongly inserting '---' characters #17

charlesdeb opened this issue Apr 30, 2011 · 5 comments

Comments

@charlesdeb
Copy link

I'm trying to convert from SQLite3 to MySQL.

As per the instructions in the readme, I ran rake db:dump and created a data.yml file which looked like it had everything in it.

I updated my database.yml to access MySQL and created the dev and test databases.

Running rake db:load successfully created the schema in the dev database, but I received an error when the script started trying to load in the data:

You have a nil object when you didn't expect it!
You might have expected an instance of Array.

Doing some debugging of the script revealed that data['records'] was not finding anything in the data.yml file. When I commented out the three hyphens --- after the word "records" for each table in the file, all the data was successfully loaded.

In other words, the following excerpt from my YAML file worked:

slugs:
columns:

  • id
  • name
  • sluggable_id
  • sequence
  • sluggable_type
  • scope
  • created_at
  • locale
    records:
    #---
  • - 1
    • home
    • 1
    • 1
    • Page
    • !!null
    • '2011-04-25 23:33:22.554123'
    • en

Worked.

There was no binary data in my very small, non-customised refinery CMS database.

@davelnewton
Copy link

AFAICT this is a syck/psych issue. After tracking down the same problem, I found this:

http://stackoverflow.com/questions/4980877/rails-error-couldnt-parse-yaml

Forcing the yamler to syck works (although I consider it a temporary fix).

@hackhowtofaq
Copy link

It doesn't solve the problem for me. Only the entries after the first and before the second '---' are parsed!

@charlesdeb
Copy link
Author

I just manually delete the ---'s in my yaml files. It's a bit of a hassle but i don't have to do it very often. I haven't actually tried to change the parser - but since it seems simple enough in the stackoverflow link that davelnewton posted a few weeks back I shall try it out next time i do a data dump, and if it doesn't fix the issue, I will repost.

@davelnewton
Copy link

It'll fix the issue, but I think someone also requested a pull of the offending line--haven't noticed if it's been accepted or not.

@hackhowtofaq
Copy link

I 'll do the same then. First parse the yaml file to remove the ---'s, because I have a huge db. Thanx for the feedback ;)

@dnrce dnrce mentioned this issue Nov 7, 2014
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

3 participants