yamldb / yaml_db

Rails plugin for a database-independent dump format, data.yml .......... Seeking new maintainers! See https://github.com/yamldb/yaml_db/issues/143
https://rubygems.org/gems/yaml_db
949 stars 200 forks source link

yaml_db 0.2.1 incompatible with YAML engine 'psych' #18

Open gamov opened 13 years ago

gamov commented 13 years ago

Hello, I use Mac OS X to develop and deploy on Linux. On my machine, there is no libyaml installed thus Ruby uses 'syck' as a yaml engine, but on Linux, it uses 'psyck' because libyaml is present.

yaml_db works perfectly with 'syck' but I noticed it fails with 'psyck' for me.

_Dumping with yamldb psych:

- - 2
  - ! '40, Obama road , #04-03  Building'
  - Singapore
  - 234332
  - SG
  - !!null

syck:

  - - 2
    - "40, Obama road , #04-03  Building"
    - Singapore
    - 577185
    - SG
    -

Loading yaml_db doesn't complain while dumping but those difference make yaml_db:load fail.

 You have a nil object when you didn't expect it!
 You might have expected an instance of Array.
 The error occurred while evaluating nil.each
 /usr/local/rvm/gems/ruby-1.9.2-p180/gems/yaml_db-0.2.1/lib/serialization_helper.rb:85:in `load_records'

it's easily reproducible (ruby 1.9.2 / rails 3.0.7):

rvm package install libyaml
rvm remove 1.9.2
rvm install 1.9.2
rails new my_app
cd my_app
rails g scaffold users name:string role:string
rake db:migrate
rake db:fixtures:load
rake db:dump 
rake db:load

` Solution Could force the parser to use syck: YAML::ENGINE.yamler= 'syck' but if user has selected his parser, this might erase his setting. Is there a way to backup user parser to put it back in place? If there is an exception is it bad?

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

kcrawford commented 13 years ago

+1

ianneub commented 13 years ago

+1 here too.

jerefrer commented 13 years ago

+1 also :)

And I can't manage to make it work using the config/boot.rb fix. Still gets the same error.

Edit : Ok got it. You also have to DUMP using Syck :)