2

All of a sudden I have this weird error when running test. rails 4.1.5 pg 0.18.1

Tried to drop and recreate databases, but nothing helps. Development seems to be working, just not tests.

RAILS_ENV=test rake db:create db:migrate

Please advise.

...gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql/
database_statements.rb:128:in `async_exec':
PG::UndefinedColumn: ERROR:  
column "table_rows" does not exist (ActiveRecord::StatementInvalid)
LINE 1: ...chema.tables WHERE table_schema = 'real_test' AND table_rows...
                                                             ^
: SELECT table_name FROM information_schema.tables WHERE table_schema = 'real_test' AND table_rows > 0
from ...ruby/gems/2.2.0/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `block in execute'
from ...ruby/gems/2.2.0/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
from ...ruby/gems/2.2.0/gems/activesupport-4.1.5/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
...

Full backtrace:

$ rspec
Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}

Randomized with seed 14295

Finished in 0.09195 seconds (files took 4.81 seconds to load)
0 examples, 0 failures

Randomized with seed 14295

/Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `async_exec': PG::UndefinedColumn: ERROR:  column "table_rows" does not exist (ActiveRecord::StatementInvalid)
LINE 1: ...chema.tables WHERE table_schema = 'real_test' AND table_rows...
                                                             ^
: SELECT table_name FROM information_schema.tables WHERE table_schema = 'real_test' AND table_rows > 0
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `block in execute'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.1.5/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql/database_statements.rb:127:in `execute'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/database_cleaner-1.4.0/lib/database_cleaner/active_record/deletion.rb:57:in `tables_with_new_rows'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/database_cleaner-1.4.0/lib/database_cleaner/active_record/deletion.rb:49:in `tables_to_truncate'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/database_cleaner-1.4.0/lib/database_cleaner/active_record/deletion.rb:80:in `block in clean'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-4.1.5/lib/active_record/connection_adapters/postgresql/referential_integrity.rb:17:in `disable_referential_integrity'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/database_cleaner-1.4.0/lib/database_cleaner/active_record/deletion.rb:79:in `clean'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/database_cleaner-1.4.0/lib/database_cleaner/base.rb:40:in `clean_with'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/database_cleaner-1.4.0/lib/database_cleaner/configuration.rb:91:in `block in clean_with'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/database_cleaner-1.4.0/lib/database_cleaner/configuration.rb:91:in `each'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/database_cleaner-1.4.0/lib/database_cleaner/configuration.rb:91:in `clean_with'
        from /Users/pain/Sites/real/spec/features/acceptance_helper.rb:40:in `block (2 levels) in <top (required)>'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/bundler/gems/rspec-core-c22e9023dacb/lib/rspec/core/example.rb:331:in `instance_exec'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/bundler/gems/rspec-core-c22e9023dacb/lib/rspec/core/example.rb:331:in `instance_exec'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/bundler/gems/rspec-core-c22e9023dacb/lib/rspec/core/hooks.rb:350:in `run'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/bundler/gems/rspec-core-c22e9023dacb/lib/rspec/core/configuration.rb:1525:in `block in run_hooks_with'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/bundler/gems/rspec-core-c22e9023dacb/lib/rspec/core/configuration.rb:1525:in `each'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/bundler/gems/rspec-core-c22e9023dacb/lib/rspec/core/configuration.rb:1525:in `run_hooks_with'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/bundler/gems/rspec-core-c22e9023dacb/lib/rspec/core/configuration.rb:1499:in `with_suite_hooks'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/bundler/gems/rspec-core-c22e9023dacb/lib/rspec/core/runner.rb:109:in `block in run_specs'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/bundler/gems/rspec-core-c22e9023dacb/lib/rspec/core/reporter.rb:62:in `report'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/bundler/gems/rspec-core-c22e9023dacb/lib/rspec/core/runner.rb:108:in `run_specs'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/bundler/gems/rspec-core-c22e9023dacb/lib/rspec/core/runner.rb:86:in `run'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/bundler/gems/rspec-core-c22e9023dacb/lib/rspec/core/runner.rb:70:in `run'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/bundler/gems/rspec-core-c22e9023dacb/lib/rspec/core/runner.rb:38:in `invoke'
        from /Users/pain/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/bundler/gems/rspec-core-c22e9023dacb/exe/rspec:4:in `<top (required)>'
        from ./bin/rspec:16:in `load'
        from ./bin/rspec:16:in `<main>'
7
  • what commands did you run to get this error ? Commented Jan 13, 2015 at 8:23
  • And what's full backtrace? Commented Jan 13, 2015 at 8:26
  • Just rspec. I'll update the original question. Commented Jan 13, 2015 at 8:27
  • Did you try running be rake db:test:prepare? Commented Jan 13, 2015 at 8:28
  • I did RAILS_ENV=test rake db:create db:migrate: WARNING: db:test:prepare is deprecated. The Rails test helper now maintains your test schema automatically, see the release notes for details. Commented Jan 13, 2015 at 8:29

1 Answer 1

4

Okay it seems the issue was with database_cleaner after upgrading from 1.3.0 to 1.4.0. Commenting out the following made tests to start working at least:

   39   config.before(:suite) do
~  40     # DatabaseCleaner.clean_with(:deletion)
   41   end

Just for the record. database_cleaner 1.4.0

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.