busca de dados de amostra do Spree dando erro no pacote de dados do rake db:

0

Tentando obter os dados de amostra do meu aplicativo de pesquisa. Utilizou os seguintes passos:

bundle exec rake railties:install:migrations
bundle exec rake db:migrate
bundle exec rake db:seed
bundle exec rake spree_sample:load

mas no bundle exec rake db:seed , o seguinte erro é lançado:

loading ruby /usr/local/rvm/gems/ruby-2.2.1/gems/spree_core-3.0.2/db/default/spree/countries.rb
rake aborted!
ActiveRecord::StatementInvalid: SQLite3::SQLException: near ",": syntax error: INSERT INTO spree_countries ("name", "iso3", "iso", "iso_name", "numcode", "states_required")
VALUES ('Andorra', 'AND', 'AD', 'ANDORRA', '020', 't') .. ('Zimbabwe', 'ZWE', 'ZW', 'ZIMBABWE', '716', 't');
/usr/local/rvm/gems/ruby-2.2.1/gems/sqlite3-1.3.10/lib/sqlite3/database.rb:91:in initialize' /usr/local/rvm/gems/ruby-2.2.1/gems/sqlite3-1.3.10/lib/sqlite3/database.rb:91:innew'
/usr/local/rvm/gems/ruby-2.2.1/gems/sqlite3-1.3.10/lib/sqlite3/database.rb:91:in prepare' /usr/local/rvm/gems/ruby-2.2.1/gems/sqlite3-1.3.10/lib/sqlite3/database.rb:134:inexecute'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/sqlite3_adapter.rb:329:in block in execute' /usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract_adapter.rb:473:inblock in log'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/notifications/instrumenter.rb:20:in instrument' /usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract_adapter.rb:467:inlog'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/sqlite3_adapter.rb:329:in execute' /usr/local/rvm/gems/ruby-2.2.1/gems/spree_core-3.0.2/db/default/spree/countries.rb:24:in'
/usr/local/rvm/gems/ruby-2.2.1/gems/polyglot-0.3.5/lib/polyglot.rb:65:in require' /usr/local/rvm/gems/ruby-2.2.1/gems/polyglot-0.3.5/lib/polyglot.rb:65:inrequire'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in block in require' /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:inload_dependency'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in require' /usr/local/rvm/gems/ruby-2.2.1/gems/spree_core-3.0.2/lib/tasks/core.rake:11:inblock (2 levels) in '
/usr/local/rvm/gems/ruby-2.2.1/gems/spree_core-3.0.2/lib/tasks/core.rake:30:in block (3 levels) in <top (required)>' /usr/local/rvm/gems/ruby-2.2.1/gems/spree_core-3.0.2/lib/tasks/core.rake:24:ineach'
/usr/local/rvm/gems/ruby-2.2.1/gems/spree_core-3.0.2/lib/tasks/core.rake:24:in block (2 levels) in <top (required)>' /usr/local/rvm/gems/ruby-2.2.1/gems/spree_core-3.0.2/db/seeds.rb:5:in'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in load' /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:inblock in load'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in load_dependency' /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:inload'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.3/lib/rails/engine.rb:547:in load_seed' /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.3/lib/rails/railtie.rb:194:inpublic_send'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.3/lib/rails/railtie.rb:194:in method_missing' /home/aparna/my_store/db/seeds.rb:10:in'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in load' /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:inblock in load'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in load_dependency' /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:inload'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.3/lib/rails/engine.rb:547:in load_seed' /usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/tasks/database_tasks.rb:250:inload_seed'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/railties/databases.rake:180:in block (2 levels) in <top (required)>' SQLite3::SQLException: near ",": syntax error /usr/local/rvm/gems/ruby-2.2.1/gems/sqlite3-1.3.10/lib/sqlite3/database.rb:91:ininitialize'
/usr/local/rvm/gems/ruby-2.2.1/gems/sqlite3-1.3.10/lib/sqlite3/database.rb:91:in new' /usr/local/rvm/gems/ruby-2.2.1/gems/sqlite3-1.3.10/lib/sqlite3/database.rb:91:inprepare'
/usr/local/rvm/gems/ruby-2.2.1/gems/sqlite3-1.3.10/lib/sqlite3/database.rb:134:in execute' /usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/sqlite3_adapter.rb:329:inblock in execute'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract_adapter.rb:473:in block in log' /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/notifications/instrumenter.rb:20:ininstrument'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract_adapter.rb:467:in log' /usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/sqlite3_adapter.rb:329:inexecute'
/usr/local/rvm/gems/ruby-2.2.1/gems/spree_core-3.0.2/db/default/spree/countries.rb:24:in <top (required)>' /usr/local/rvm/gems/ruby-2.2.1/gems/polyglot-0.3.5/lib/polyglot.rb:65:inrequire'
/usr/local/rvm/gems/ruby-2.2.1/gems/polyglot-0.3.5/lib/polyglot.rb:65:in require' /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:inblock in require'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in load_dependency' /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:inrequire'
/usr/local/rvm/gems/ruby-2.2.1/gems/spree_core-3.0.2/lib/tasks/core.rake:11:in block (2 levels) in <top (required)>' /usr/local/rvm/gems/ruby-2.2.1/gems/spree_core-3.0.2/lib/tasks/core.rake:30:inblock (3 levels) in '
/usr/local/rvm/gems/ruby-2.2.1/gems/spree_core-3.0.2/lib/tasks/core.rake:24:in each' /usr/local/rvm/gems/ruby-2.2.1/gems/spree_core-3.0.2/lib/tasks/core.rake:24:inblock (2 levels) in '
/usr/local/rvm/gems/ruby-2.2.1/gems/spree_core-3.0.2/db/seeds.rb:5:in <top (required)>' /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:inload'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in block in load' /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:inload_dependency'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in load' /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.3/lib/rails/engine.rb:547:inload_seed'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.3/lib/rails/railtie.rb:194:in public_send' /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.3/lib/rails/railtie.rb:194:inmethod_missing'
/home/aparna/my_store/db/seeds.rb:10:in <top (required)>' /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:inload'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in block in load' /usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:inload_dependency'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in load' /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.3/lib/rails/engine.rb:547:inload_seed'
/usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/tasks/database_tasks.rb:250:in load_seed' /usr/local/rvm/gems/ruby-2.2.1/gems/activerecord-4.2.3/lib/active_record/railties/databases.rake:180:inblock (2 levels) in '
Tasks: TOP => db:load_dir
(See full trace by running task with --trace)

Alguma ideia do que deve ser feito?

    
por ap2705 08.08.2015 / 14:36

2 respostas

1

oh spree.

há algo errado com as instruções sql geradas nos arquivos de semente do país / estados.

aqui está o meu substituto, que é mais lento mas funciona

spree_core/db/default/spree/countries.rb

require 'carmen'

Carmen::Country.all.map do |country|
  name = country.name
  iso3 = country.alpha_3_code
  iso = country.alpha_2_code
  iso_name = country.name.upcase
  numcode = country.numeric_code
  states_required = country.subregions?

  # country_inserts << [name, iso3, iso, iso_name, numcode, states_required].join(", ")
  Spree::Country.new(      :name => name,
      :iso3 => iso3,
      :iso => iso,
      :iso_name => iso_name,
      :numcode => numcode,
      :states_required => states_required
  ).save!
end

canada = Spree::Country.find_by(iso: "CA")
Spree::Config[:default_country_id] = canada.id

e

spree_core/db/default/spree/states.rb

connection = ActiveRecord::Base.connection
state_inserts = []

Spree::Country.where(states_required: true).each do |country|
  carmen_country = Carmen::Country.named(country.name)
  carmen_country.subregions.each do |subregion|
    name = connection.quote subregion.name
    abbr = connection.quote subregion.code
    country_id = connection.quote country.id

    state_inserts << [name, abbr, country_id].join(", ")
    Spree::State.new(:name => name, :abbr => abbr, :country_id => country_id).save!
  end
end
    
por Tom Carchrae 09.08.2015 / 07:12
0

As especificações do Spree normalmente usam a versão mais recente do SQLite. Eu estou supondo que isso não foi detectado, uma vez que nunca testamos antes de 3.7.11. Eu diria que o problema é que o SQLite DB está desatualizado. Não consigo ver o Spree querendo suportar uma versão antiga do SQLite.

Eu estou supondo que você é DB é pré-3.7.11. Se for, você pode atualizá-lo?

    
por BenMorganIO 12.10.2015 / 07:52