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 199 forks source link

Nil.each #21

Open Gerhardk opened 13 years ago

Gerhardk commented 13 years ago

Hey

I am trying to migrate for n postgres database to mysql. When I run rake db:dump everything works. When I run rake db:load it gives me an nil.each error. I know I have empty tables, can you advise what I need to do.

Thanks

dimitarvp commented 13 years ago

Dumped MySQL production DB without a problem

Tried importing it into development SQLite3 DB and I got this:

... * Invoke db:data:load (first_time) * Invoke environment \ Execute db:data:load rake aborted! 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 C:/code/testmysql/vendor/plugins/yaml_db/lib/serialization_helper.rb:85:in load_records' C:/code/testmysql/vendor/plugins/yaml_db/lib/serialization_helper.rb:74:inload_table' C:/code/testmysql/vendor/plugins/yaml_db/lib/yaml_db.rb:63:in block (2 levels) in load_documents' C:/code/testmysql/vendor/plugins/yaml_db/lib/yaml_db.rb:61:ineach' C:/code/testmysql/vendor/plugins/yaml_db/lib/yaml_db.rb:61:in block in load_documents' C:/Ruby192/lib/ruby/1.9.1/psych/deprecated.rb:30:ineach' C:/Ruby192/lib/ruby/1.9.1/psych/deprecated.rb:30:in load_documents' C:/code/testmysql/vendor/plugins/yaml_db/lib/yaml_db.rb:60:inload_documents' C:/code/testmysql/vendor/plugins/yaml_db/lib/serialization_helper.rb:57:in block in load' C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/database _statements.rb:139:intransaction' C:/code/testmysql/vendor/plugins/yaml_db/lib/serialization_helper.rb:56:in load' C:/code/testmysql/vendor/plugins/yaml_db/lib/serialization_helper.rb:31:inload' C:/code/testmysql/vendor/plugins/yaml_db/lib/tasks/yaml_db_tasks.rake:35:in block (3 levels) in <top (require d)>' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:205:incall' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:205:in block in execute' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:200:ineach' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:200:in execute' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:158:inblock in invoke_with_call_chain' C:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in mon_synchronize' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:151:ininvoke_with_call_chain' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:176:in block in invoke_prerequisites' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:174:ineach' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:174:in invoke_prerequisites' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:157:inblock in invoke_with_call_chain' C:/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in mon_synchronize' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:151:ininvoke_with_call_chain' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/task.rb:144:in invoke' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:112:ininvoke_task' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in block (2 levels) in top_level' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:ineach' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:90:in block in top_level' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:129:instandard_exception_handling' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:84:in top_level' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:62:inblock in run' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:129:in standard_exception_handling' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/lib/rake/application.rb:59:inrun' C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.2/bin/rake:32:in <top (required)>' C:/Ruby192/bin/rake:19:inload' C:/Ruby192/bin/rake:19:in `

' Tasks: TOP => db:load => db:data:load

janlelis commented 13 years ago

might be this bug: https://github.com/ludicast/yaml_db/issues/18 (use syck for dumping)

wejrowski commented 13 years ago

I'm on EngineYard and I'm trying to use the yaml_db gem to load data I had locally that I saved to db/data.yml with the gem. I'm running

rake db:data:load

And I'm getting this same exact error. I've tried forcing the YAML engine to syck and also tried psych on Engineyard but neither is working. I'm not sure how to load the yml file.

Any ideas?

fivetwentysix commented 13 years ago

Same here

[master][~/Sites/boss-mocha] bundle exec rake db:data:load --trace
*\* Invoke db:data:load (first_time)
*\* Invoke environment (first_time)
*\* Execute environment
*\* Execute db:data:load
rake aborted!
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
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/serialization_helper.rb:85:in `load_records'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/serialization_helper.rb:74:in`load_table'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/yaml_db.rb:63:in `block (2 levels) in load_documents'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/yaml_db.rb:61:in`each'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/yaml_db.rb:61:in `block in load_documents'
/Users/pma/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/syck.rb:235:in`call'
/Users/pma/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/syck.rb:235:in `load_documents'
/Users/pma/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/syck.rb:235:in`load_documents'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/yaml_db.rb:60:in `load_documents'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/serialization_helper.rb:57:in`block in load'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/serialization_helper.rb:56:in`load'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/serialization_helper.rb:31:in `load'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/yaml_db-0.2.1/lib/tasks/yaml_db_tasks.rake:35:in`block (3 levels) in <top (required)>'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/task.rb:205:in`block in execute'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/task.rb:200:in`execute'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/pma/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in`mon_synchronize'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/task.rb:144:in`invoke'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:90:in`block (2 levels) in top_level'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:90:in`block in top_level'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:84:in`top_level'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:129:in`standard_exception_handling'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/bin/rake:32:in`<top (required)>'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `load'
/Users/pma/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in`<main>'
Tasks: TOP => db:data:load

Gemfile.lock

GIT
  remote: git://github.com/jeanmartin/paperclip.git
  revision: 4095e07adaace2a123cbd031fa268928f3b0ce87
  specs:
    paperclip (2.3.10)
      activerecord (>= 2.3.0)
      activesupport (>= 2.3.2)

GEM
  remote: http://rubygems.org/
  specs:
    Saikuro (1.1.0)
    abstract (1.0.0)
    actionmailer (3.0.10)
      actionpack (= 3.0.10)
      mail (~> 2.2.19)
    actionpack (3.0.10)
      activemodel (= 3.0.10)
      activesupport (= 3.0.10)
      builder (~> 2.1.2)
      erubis (~> 2.6.6)
      i18n (~> 0.5.0)
      rack (~> 1.2.1)
      rack-mount (~> 0.6.14)
      rack-test (~> 0.5.7)
      tzinfo (~> 0.3.23)
    activemodel (3.0.10)
      activesupport (= 3.0.10)
      builder (~> 2.1.2)
      i18n (~> 0.5.0)
    activerecord (3.0.10)
      activemodel (= 3.0.10)
      activesupport (= 3.0.10)
      arel (~> 2.0.10)
      tzinfo (~> 0.3.23)
    activeresource (3.0.10)
      activemodel (= 3.0.10)
      activesupport (= 3.0.10)
    activesupport (3.0.10)
    acts_as_audited (2.0.0.rc7)
      rails (>= 3.0.3)
    addressable (2.2.6)
    arel (2.0.10)
    bcrypt-ruby (2.1.4)
    builder (2.1.2)
    capistrano (2.8.0)
      highline
      net-scp (>= 1.0.0)
      net-sftp (>= 2.0.0)
      net-ssh (>= 2.0.14)
      net-ssh-gateway (>= 1.1.0)
    capybara (1.0.1)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      selenium-webdriver (~> 2.0)
      xpath (~> 0.1.4)
    capybara-webkit (0.6.0)
      capybara (~> 1.0.0)
    childprocess (0.2.1)
      ffi (~> 1.0.6)
    chronic (0.3.0)
    churn (0.0.13)
      chronic (>= 0.2.3)
      hirb
      json_pure
      main
      ruby_parser (~> 2.0.4)
      sexp_processor (~> 3.0.3)
    colored (1.2)
    cucumber (1.0.2)
      builder (>= 2.1.2)
      diff-lcs (>= 1.1.2)
      gherkin (~> 2.4.5)
      json (>= 1.4.6)
      term-ansicolor (>= 1.0.5)
    cucumber-rails (1.0.2)
      capybara (>= 1.0.0)
      cucumber (~> 1.0.0)
      nokogiri (>= 1.4.6)
    database_cleaner (0.6.7)
    devise (1.4.2)
      bcrypt-ruby (~> 2.1.2)
      orm_adapter (~> 0.0.3)
      warden (~> 1.0.3)
    diff-lcs (1.1.2)
    erubis (2.6.6)
      abstract (>= 1.0.0)
    escape_utils (0.2.3)
    factory_girl (2.0.4)
    factory_girl_rails (1.1.0)
      factory_girl (~> 2.0.0)
      railties (>= 3.0.0)
    ffi (1.0.9)
    flay (1.4.3)
      ruby_parser (~> 2.0)
      sexp_processor (~> 3.0)
    flog (2.5.2)
      ruby_parser (~> 2.0)
      sexp_processor (~> 3.0)
    gherkin (2.4.15)
      json (>= 1.4.6)
    google_currency (1.2.0)
      money (~> 3.5)
    growl (1.0.3)
    haml (3.1.2)
    highline (1.6.2)
    hirb (0.5.0)
    i18n (0.5.0)
    jquery-rails (1.0.13)
      railties (~> 3.0)
      thor (~> 0.14)
    json (1.5.3)
    json_pure (1.5.3)
    launchy (2.0.5)
      addressable (~> 2.2.6)
    mail (2.2.19)
      activesupport (>= 2.3.6)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    main (4.7.1)
    memcache (1.2.13)
    memcache-client (1.8.5)
    meta_where (1.0.4)
      activerecord (~> 3.0.0)
      activesupport (~> 3.0.0)
      arel (~> 2.0.7)
    metric_fu (2.1.1)
      Saikuro (>= 1.1.0)
      activesupport (>= 2.0.0)
      chronic (~> 0.3.0)
      churn (>= 0.0.7)
      flay (>= 1.2.1)
      flog (>= 2.3.0)
      rails_best_practices (>= 0.6.4)
      rcov (>= 0.8.3.3)
      reek (>= 1.2.6)
      roodi (>= 2.1.0)
      syntax
    mime-types (1.16)
    money (3.7.1)
      i18n (~> 0.4)
    net-scp (1.0.4)
      net-ssh (>= 1.99.1)
    net-sftp (2.0.5)
      net-ssh (>= 2.0.9)
    net-ssh (2.2.0)
    net-ssh-gateway (1.1.0)
      net-ssh (>= 1.99.1)
    nokogiri (1.5.0)
    orm_adapter (0.0.5)
    pg (0.11.0)
    polyglot (0.3.2)
    rack (1.2.3)
    rack-mount (0.6.14)
      rack (>= 1.0.0)
    rack-test (0.5.7)
      rack (>= 1.0)
    rails (3.0.10)
      actionmailer (= 3.0.10)
      actionpack (= 3.0.10)
      activerecord (= 3.0.10)
      activeresource (= 3.0.10)
      activesupport (= 3.0.10)
      bundler (~> 1.0)
      railties (= 3.0.10)
    rails_best_practices (0.10.1)
      activesupport
      colored
      erubis
      haml
      i18n
      ruby-progressbar
      ruby_parser
    railties (3.0.10)
      actionpack (= 3.0.10)
      activesupport (= 3.0.10)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (~> 0.14.4)
    rake (0.9.2)
    rb-fsevent (0.4.3.1)
    rcov (0.9.10)
    rdoc (3.9.3)
    reek (1.2.8)
      ruby2ruby (~> 1.2)
      ruby_parser (~> 2.0)
      sexp_processor (~> 3.0)
    roodi (2.1.0)
      ruby_parser
    rspec (2.6.0)
      rspec-core (~> 2.6.0)
      rspec-expectations (~> 2.6.0)
      rspec-mocks (~> 2.6.0)
    rspec-core (2.6.4)
    rspec-expectations (2.6.0)
      diff-lcs (~> 1.1.2)
    rspec-mocks (2.6.0)
    rspec-rails (2.6.1)
      actionpack (~> 3.0)
      activesupport (~> 3.0)
      railties (~> 3.0)
      rspec (~> 2.6.0)
    ruby-progressbar (0.0.10)
    ruby2ruby (1.2.5)
      ruby_parser (~> 2.0)
      sexp_processor (~> 3.0)
    ruby_parser (2.0.6)
      sexp_processor (~> 3.0)
    rubyzip (0.9.4)
    sass (3.1.7)
    selenium-webdriver (2.5.0)
      childprocess (>= 0.2.1)
      ffi (>= 1.0.7)
      json_pure
      rubyzip
    sexp_processor (3.0.6)
    shoulda (2.11.3)
    syntax (1.0.0)
    term-ansicolor (1.0.6)
    thor (0.14.6)
    treetop (1.4.10)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.29)
    warden (1.0.5)
      rack (>= 1.0)
    xpath (0.1.4)
      nokogiri (~> 1.3)
    yaml_db (0.2.1)

PLATFORMS
  ruby

DEPENDENCIES
  acts_as_audited (= 2.0.0.rc7)
  capistrano
  capybara
  capybara-webkit
  cucumber
  cucumber-rails
  database_cleaner
  devise
  escape_utils
  factory_girl
  factory_girl_rails
  google_currency
  growl
  haml
  jquery-rails
  json
  launchy
  memcache
  memcache-client
  meta_where
  metric_fu
  mime-types
  money
  paperclip!
  pg
  rails (= 3.0.10)
  rb-fsevent
  rspec-rails
  sass
  shoulda
  warden
  yaml_db
wejrowski commented 13 years ago

So I had figured it out earlier. Syck was the answer. Try placing in this in your boot.rb file on local or dev:

YAML::ENGINE.yamler= 'syck'
fivetwentysix commented 13 years ago

Yeah, the 'syck' thing doesn't work for me.

dimitarvp commented 13 years ago

And plus, isn't there a test suite for testing a reference implementation of YAML? How about not releasing incompatible software (as Psych mostly turns out to be)? :-(

bricestacey commented 13 years ago

I had this same problem and it was solved by using syck.

tleach commented 12 years ago

I had this problem too and "worked around" it by simply ensuring all of my tables contained at least a single record before dumping them. It's somewhat inconvenient though...

kalabiyau commented 12 years ago

i my case bug is confirmed like in @tomtheguvnor 's situation. If in source db there is some blank table - load on destination will fail with syck and psych both

dnrce commented 9 years ago

This is the same error as in #17.