`type_cast_pluck_values': undefined method `columns' for nil:NilClass (NoMethodError)
BambangSinaga opened this issue · comments
Just tried this gem using latest version, on rails 6 api with postgres on my local environment today and got this issue when starting rails console or first hit api for rails server
NoMethodError (undefined method `columns' for nil:NilClass):
activerecord (6.1.6) lib/active_record/relation/calculations.rb:432:in `type_cast_pluck_values'
activerecord (6.1.6) lib/active_record/relation/calculations.rb:203:in `pluck'
activerecord (6.1.6) lib/active_record/schema_migration.rb:46:in `all_versions'
activerecord (6.1.6) lib/active_record/migration.rb:1109:in `get_all_versions'
activerecord (6.1.6) lib/active_record/migration.rb:1121:in `needs_migration?'
activerecord (6.1.6) lib/active_record/migration.rb:625:in `check_pending!'
activerecord (6.1.6) lib/active_record/migration.rb:590:in `block (2 levels) in call'
activesupport (6.1.6) lib/active_support/evented_file_update_checker.rb:59:in `execute'
activerecord (6.1.6) lib/active_record/migration.rb:595:in `block in call'
activerecord (6.1.6) lib/active_record/migration.rb:587:in `synchronize'
activerecord (6.1.6) lib/active_record/migration.rb:587:in `call'
actionpack (6.1.6) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.1.6) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (6.1.6) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.1.6) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.1.6) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
actionpack (6.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
actionpack (6.1.6) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.1.6) lib/rails/rack/logger.rb:37:in `call_app'
railties (6.1.6) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.1.6) lib/active_support/tagged_logging.rb:99:in `block in tagged'
activesupport (6.1.6) lib/active_support/tagged_logging.rb:37:in `tagged'
activesupport (6.1.6) lib/active_support/tagged_logging.rb:99:in `tagged'
railties (6.1.6) lib/rails/rack/logger.rb:26:in `call'
actionpack (6.1.6) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (6.1.6) lib/action_dispatch/middleware/request_id.rb:26:in `call'
rack (2.2.3) lib/rack/runtime.rb:22:in `call'
activesupport (6.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.1.6) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.1.6) lib/action_dispatch/middleware/static.rb:24:in `call'
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
actionpack (6.1.6) lib/action_dispatch/middleware/host_authorization.rb:148:in `call'
railties (6.1.6) lib/rails/engine.rb:539:in `call'
puma (5.6.4) lib/puma/configuration.rb:252:in `call'
puma (5.6.4) lib/puma/request.rb:77:in `block in handle_request'
puma (5.6.4) lib/puma/thread_pool.rb:340:in `with_force_shutdown'
puma (5.6.4) lib/puma/request.rb:76:in `handle_request'
puma (5.6.4) lib/puma/server.rb:441:in `process_client'
puma (5.6.4) lib/puma/thread_pool.rb:147:in `block in spawn_thread'
Hey @BambangSinaga, thanks for reporting. Which Makara adapter are you using, and do you get the same error with only Makara?
I tried to change from latest version(0.5.1) to 0.5.0 and 0.4.1 but still got the same error @ankane . FYI I tried this on fresh rails api with postgres database
I'm not sure how to reproduce, but if you can narrow it down to Distribute Reads and not Makara, happy to look into it more.
I am not found any error when only use makara
this issue happen when I use postgresql_makara
as adapter, but when I change to postgresql
this didn't happen.
here is my database.yaml
development:
<<: *default
database: super_awesome_api_development
makara:
# optional id to identify the proxy with this configuration for stickiness
id: postgresql
# the following are default values
blacklist_duration: 5
primary_ttl: 5
primary_strategy: round_robin
sticky: false
# list your connections with the override values (they're merged into the top-level config)
# be sure to provide the role if primary, role is assumed to be a replica if not provided
connections:
- role: primary
host: localhost
- role: replica
host: localhost
should I use postgresql
as adapter when using distributed_gem @ankane ?
The role needs to be master
instead of primary
(primary
is only available with makara 0.6.0.pre). See the config in the readme: https://github.com/ankane/distribute_reads#how-to-use
wahh.. thanks ya, yes return success now, the docs didn't state to use master for 0.5.1
Thanks again @ankane