owen2345 / camaleon-cms

Camaleon CMS is a dynamic and advanced content management system based on Ruby on Rails
https://camaleon.website
MIT License
1.21k stars 285 forks source link

PG::UndefinedFunction: ERROR: function lower(boolean) when searching in admin panel #866

Closed mariusz-blaszczak closed 5 years ago

mariusz-blaszczak commented 5 years ago

When I run search in post index in admin: image

I am getting this error:

ActiveRecord::StatementInvalid (PG::UndefinedFunction: ERROR:  function lower(boolean) does not exist
LINE 1: ...= $4 AND (LOWER(cama_posts.title) LIKE '%abq%' OR LOWER(cama...
                                                             ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
: SELECT COUNT(DISTINCT "cama_posts"."id") FROM "cama_posts" LEFT OUTER JOIN "cama_posts" "parents_cama_posts" ON "parents_cama_posts"."id" = "cama_posts"."post_parent" AND "parents_cama_posts"."post_class" = $1 LEFT OUTER JOIN "cama_term_taxonomy" ON "cama_term_taxonomy"."id" = "cama_posts"."taxonomy_id" AND "cama_term_taxonomy"."taxonomy" = $2 WHERE "cama_posts"."post_class" = $3 AND "cama_posts"."taxonomy_id" = $4 AND (LOWER(cama_posts.title) LIKE '%abq%' OR LOWER(cama_posts.slug LIKE '%abq%')) AND "cama_posts"."status" = $5):

activerecord (5.2.2) lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `async_exec_params'
activerecord (5.2.2) lib/active_record/connection_adapters/postgresql_adapter.rb:611:in `block (2 levels) in exec_no_cache'
activesupport (5.2.2) lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
activesupport (5.2.2) lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
activesupport (5.2.2) lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
activerecord (5.2.2) lib/active_record/connection_adapters/postgresql_adapter.rb:610:in `block in exec_no_cache'
activerecord (5.2.2) lib/active_record/connection_adapters/abstract_adapter.rb:579:in `block (2 levels) in log'
/Users/mariusz/.rbenv/versions/2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
activerecord (5.2.2) lib/active_record/connection_adapters/abstract_adapter.rb:578:in `block in log'
activesupport (5.2.2) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activerecord (5.2.2) lib/active_record/connection_adapters/abstract_adapter.rb:569:in `log'
activerecord (5.2.2) lib/active_record/connection_adapters/postgresql_adapter.rb:609:in `exec_no_cache'
activerecord (5.2.2) lib/active_record/connection_adapters/postgresql_adapter.rb:598:in `execute_and_clear'
activerecord (5.2.2) lib/active_record/connection_adapters/postgresql/database_statements.rb:81:in `exec_query'
activerecord (5.2.2) lib/active_record/connection_adapters/abstract/database_statements.rb:470:in `select'
activerecord (5.2.2) lib/active_record/connection_adapters/abstract/database_statements.rb:62:in `select_all'
activerecord (5.2.2) lib/active_record/connection_adapters/abstract/query_cache.rb:99:in `block in select_all'
activerecord (5.2.2) lib/active_record/connection_adapters/abstract/query_cache.rb:122:in `block in cache_sql'
/Users/mariusz/.rbenv/versions/2.5.3/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
activerecord (5.2.2) lib/active_record/connection_adapters/abstract/query_cache.rb:108:in `cache_sql'
activerecord (5.2.2) lib/active_record/connection_adapters/abstract/query_cache.rb:99:in `select_all'
activerecord (5.2.2) lib/active_record/relation/calculations.rb:282:in `block in execute_simple_calculation'
activerecord (5.2.2) lib/active_record/relation.rb:584:in `skip_query_cache_if_necessary'
activerecord (5.2.2) lib/active_record/relation/calculations.rb:282:in `execute_simple_calculation'
activerecord (5.2.2) lib/active_record/relation/calculations.rb:238:in `perform_calculation'
activerecord (5.2.2) lib/active_record/relation/calculations.rb:145:in `calculate'
activerecord (5.2.2) lib/active_record/relation/calculations.rb:143:in `calculate'
activerecord (5.2.2) lib/active_record/relation/calculations.rb:52:in `count'
activerecord (5.2.2) lib/active_record/relation.rb:211:in `size'
camaleon_cms (2.4.5.12) app/controllers/camaleon_cms/admin/posts_controller.rb:51:in `index'
actionpack (5.2.2) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (5.2.2) lib/abstract_controller/base.rb:194:in `process_action'
actionpack (5.2.2) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.2.2) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (5.2.2) lib/active_support/callbacks.rb:132:in `run_callbacks'
actionpack (5.2.2) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (5.2.2) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (5.2.2) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (5.2.2) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.2) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.2) lib/active_support/notifications.rb:168:in `instrument'
actionpack (5.2.2) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (5.2.2) lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
activerecord (5.2.2) lib/active_record/railties/controller_runtime.rb:24:in `process_action'
actionpack (5.2.2) lib/abstract_controller/base.rb:134:in `process'
actionview (5.2.2) lib/action_view/rendering.rb:32:in `process'
actionpack (5.2.2) lib/action_controller/metal.rb:191:in `dispatch'
actionpack (5.2.2) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (5.2.2) lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
actionpack (5.2.2) lib/action_dispatch/routing/route_set.rb:34:in `serve'
actionpack (5.2.2) lib/action_dispatch/journey/router.rb:52:in `block in serve'
actionpack (5.2.2) lib/action_dispatch/journey/router.rb:35:in `each'
actionpack (5.2.2) lib/action_dispatch/journey/router.rb:35:in `serve'
actionpack (5.2.2) lib/action_dispatch/routing/route_set.rb:840:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.6) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.0.6) lib/rack/etag.rb:25:in `call'
rack (2.0.6) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.6) lib/rack/head.rb:12:in `call'
actionpack (5.2.2) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.0.6) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.6) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/cookies.rb:670:in `call'
activerecord (5.2.2) lib/active_record/migration.rb:559:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (5.2.2) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (5.2.2) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.7.0) lib/web_console/middleware.rb:30:in `block in call'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.2) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.2) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.2) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.2) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.2) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
request_store (1.4.1) lib/request_store/middleware.rb:19:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.6) lib/rack/method_override.rb:22:in `call'
rack (2.0.6) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.2) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.6) lib/rack/sendfile.rb:111:in `call'
webpacker (3.5.5) lib/webpacker/dev_server_proxy.rb:22:in `perform_request'
rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
railties (5.2.2) lib/rails/engine.rb:524:in `call'
rack (2.0.6) lib/rack/urlmap.rb:68:in `block in call'
rack (2.0.6) lib/rack/urlmap.rb:53:in `each'
rack (2.0.6) lib/rack/urlmap.rb:53:in `call'
puma (3.12.0) lib/puma/configuration.rb:225:in `call'
puma (3.12.0) lib/puma/server.rb:658:in `handle_request'
puma (3.12.0) lib/puma/server.rb:472:in `process_client'
puma (3.12.0) lib/puma/server.rb:332:in `block in run'
puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'

My Gemfile.lock

GIT
  remote: https://github.com/owen2345/camaleon-post-order-plugin.git
  revision: 3c665b27166084be6b99142cde837d0195080e60
  specs:
    camaleon_post_order (0.0.2)
      rails

GEM
  remote: https://rubygems.org/
  specs:
    actioncable (5.2.2)
      actionpack (= 5.2.2)
      nio4r (~> 2.0)
      websocket-driver (>= 0.6.1)
    actionmailer (5.2.2)
      actionpack (= 5.2.2)
      actionview (= 5.2.2)
      activejob (= 5.2.2)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 2.0)
    actionpack (5.2.2)
      actionview (= 5.2.2)
      activesupport (= 5.2.2)
      rack (~> 2.0)
      rack-test (>= 0.6.3)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview (5.2.2)
      activesupport (= 5.2.2)
      builder (~> 3.1)
      erubi (~> 1.4)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.3)
    activejob (5.2.2)
      activesupport (= 5.2.2)
      globalid (>= 0.3.6)
    activemodel (5.2.2)
      activesupport (= 5.2.2)
    activemodel-serializers-xml (1.0.2)
      activemodel (> 5.x)
      activesupport (> 5.x)
      builder (~> 3.1)
    activerecord (5.2.2)
      activemodel (= 5.2.2)
      activesupport (= 5.2.2)
      arel (>= 9.0)
    activestorage (5.2.2)
      actionpack (= 5.2.2)
      activerecord (= 5.2.2)
      marcel (~> 0.3.1)
    activesupport (5.2.2)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (>= 0.7, < 2)
      minitest (~> 5.1)
      tzinfo (~> 1.1)
    airbrussh (1.3.1)
      sshkit (>= 1.6.1, != 1.7.0)
    arel (9.0.0)
    ast (2.4.0)
    aws-sdk (2.11.194)
      aws-sdk-resources (= 2.11.194)
    aws-sdk-core (2.11.194)
      aws-sigv4 (~> 1.0)
      jmespath (~> 1.0)
    aws-sdk-resources (2.11.194)
      aws-sdk-core (= 2.11.194)
    aws-sigv4 (1.0.3)
    bcrypt (3.1.12)
    bindex (0.5.0)
    binding_of_caller (0.8.0)
      debug_inspector (>= 0.0.1)
    bootsnap (1.3.2)
      msgpack (~> 1.0)
    breadcrumbs_on_rails (3.0.1)
    builder (3.2.3)
    byebug (10.0.2)
    cama_contact_form (0.0.27)
      rails
      recaptcha
    cama_meta_tag (1.5)
      rails (>= 4.1.0)
    camaleon_cms (2.4.5.12)
      aws-sdk (~> 2)
      bcrypt
      breadcrumbs_on_rails
      cama_contact_form (~> 0.0.16)
      cama_meta_tag
      cancancan (~> 2.0)
      coffee-rails
      draper (>= 1.3)
      font-awesome-rails
      jquery-rails
      meta-tags (~> 2.0)
      mini_magick
      sass-rails (<= 5.0.7)
      tinymce-rails (~> 4.3)
      will_paginate
      will_paginate-bootstrap
    cancancan (2.3.0)
    capistrano (3.11.0)
      airbrussh (>= 1.0.0)
      i18n
      rake (>= 10.0.0)
      sshkit (>= 1.9.0)
    capistrano-copy-files (0.0.1)
      capistrano (>= 3.0.0)
    capose (0.2.0)
      capistrano (~> 3.7)
    childprocess (0.9.0)
      ffi (~> 1.0, >= 1.0.11)
    coderay (1.1.2)
    coffee-rails (4.2.2)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.12.2)
    concurrent-ruby (1.1.3)
    crass (1.0.4)
    data_migrate (5.3.0)
      rails (>= 4.2)
    debug_inspector (0.0.3)
    diff-lcs (1.3)
    draper (3.0.1)
      actionpack (~> 5.0)
      activemodel (~> 5.0)
      activemodel-serializers-xml (~> 1.0)
      activesupport (~> 5.0)
      request_store (~> 1.0)
    erubi (1.7.1)
    execjs (2.7.0)
    factory_bot (4.11.1)
      activesupport (>= 3.0.0)
    factory_bot_rails (4.11.1)
      factory_bot (~> 4.11.1)
      railties (>= 3.0.0)
    faker (1.9.1)
      i18n (>= 0.7)
    ffi (1.9.25)
    font-awesome-rails (4.7.0.4)
      railties (>= 3.2, < 6.0)
    globalid (0.4.1)
      activesupport (>= 4.2.0)
    i18n (1.2.0)
      concurrent-ruby (~> 1.0)
    iniparse (1.4.4)
    jaro_winkler (1.5.1)
    jmespath (1.4.0)
    jquery-rails (4.3.3)
      rails-dom-testing (>= 1, < 3)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    json (2.1.0)
    listen (3.1.5)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
      ruby_dep (~> 1.2)
    loofah (2.2.3)
      crass (~> 1.0.2)
      nokogiri (>= 1.5.9)
    mail (2.7.1)
      mini_mime (>= 0.1.1)
    marcel (0.3.3)
      mimemagic (~> 0.3.2)
    meta-tags (2.11.0)
      actionpack (>= 3.2.0, < 5.3)
    method_source (0.9.2)
    mimemagic (0.3.2)
    mini_magick (4.9.2)
    mini_mime (1.0.1)
    mini_portile2 (2.3.0)
    minitest (5.11.3)
    msgpack (1.2.4)
    net-scp (1.2.1)
      net-ssh (>= 2.6.5)
    net-ssh (5.0.2)
    nio4r (2.3.1)
    nokogiri (1.8.5)
      mini_portile2 (~> 2.3.0)
    overcommit (0.46.0)
      childprocess (~> 0.6, >= 0.6.3)
      iniparse (~> 1.4)
    parallel (1.12.1)
    parser (2.5.3.0)
      ast (~> 2.4.0)
    pg (1.1.3)
    powerpack (0.1.2)
    pry (0.12.2)
      coderay (~> 1.1.0)
      method_source (~> 0.9.0)
    pry-byebug (3.6.0)
      byebug (~> 10.0)
      pry (~> 0.10)
    pry-rails (0.3.8)
      pry (>= 0.10.4)
    pry-stack_explorer (0.4.9.3)
      binding_of_caller (>= 0.7)
      pry (>= 0.9.11)
    puma (3.12.0)
    rack (2.0.6)
    rack-proxy (0.6.5)
      rack
    rack-test (1.1.0)
      rack (>= 1.0, < 3)
    rails (5.2.2)
      actioncable (= 5.2.2)
      actionmailer (= 5.2.2)
      actionpack (= 5.2.2)
      actionview (= 5.2.2)
      activejob (= 5.2.2)
      activemodel (= 5.2.2)
      activerecord (= 5.2.2)
      activestorage (= 5.2.2)
      activesupport (= 5.2.2)
      bundler (>= 1.3.0)
      railties (= 5.2.2)
      sprockets-rails (>= 2.0.0)
    rails-dom-testing (2.0.3)
      activesupport (>= 4.2.0)
      nokogiri (>= 1.6)
    rails-html-sanitizer (1.0.4)
      loofah (~> 2.2, >= 2.2.2)
    railties (5.2.2)
      actionpack (= 5.2.2)
      activesupport (= 5.2.2)
      method_source
      rake (>= 0.8.7)
      thor (>= 0.19.0, < 2.0)
    rainbow (3.0.0)
    rake (12.3.2)
    rb-fsevent (0.10.3)
    rb-inotify (0.9.10)
      ffi (>= 0.5.0, < 2)
    recaptcha (4.13.1)
      json
    request_store (1.4.1)
      rack (>= 1.4)
    rspec-core (3.8.0)
      rspec-support (~> 3.8.0)
    rspec-expectations (3.8.2)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.8.0)
    rspec-mocks (3.8.0)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.8.0)
    rspec-rails (3.8.1)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec-core (~> 3.8.0)
      rspec-expectations (~> 3.8.0)
      rspec-mocks (~> 3.8.0)
      rspec-support (~> 3.8.0)
    rspec-support (3.8.0)
    rubocop (0.61.1)
      jaro_winkler (~> 1.5.1)
      parallel (~> 1.10)
      parser (>= 2.5, != 2.5.1.1)
      powerpack (~> 0.1)
      rainbow (>= 2.2.2, < 4.0)
      ruby-progressbar (~> 1.7)
      unicode-display_width (~> 1.4.0)
    ruby-progressbar (1.10.0)
    ruby_dep (1.5.0)
    sass (3.7.2)
      sass-listen (~> 4.0.0)
    sass-listen (4.0.0)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
    sass-rails (5.0.7)
      railties (>= 4.0.0, < 6)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (>= 1.1, < 3)
    seed_dump (3.3.1)
      activerecord (>= 4)
      activesupport (>= 4)
    spring (2.0.2)
      activesupport (>= 4.2)
    spring-commands-rspec (1.0.4)
      spring (>= 0.9.1)
    spring-watcher-listen (2.0.1)
      listen (>= 2.7, < 4.0)
      spring (>= 1.2, < 3.0)
    sprockets (3.7.2)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.2.1)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    sshkit (1.18.0)
      net-scp (>= 1.1.2)
      net-ssh (>= 2.8.0)
    thor (0.20.3)
    thread_safe (0.3.6)
    tilt (2.0.9)
    timecop (0.9.1)
    tinymce-rails (4.9.2)
      railties (>= 3.1.1)
    tzinfo (1.2.5)
      thread_safe (~> 0.1)
    uglifier (4.1.20)
      execjs (>= 0.3.0, < 3)
    unicode-display_width (1.4.0)
    web-console (3.7.0)
      actionview (>= 5.0)
      activemodel (>= 5.0)
      bindex (>= 0.4.0)
      railties (>= 5.0)
    webpacker (3.5.5)
      activesupport (>= 4.2)
      rack-proxy (>= 0.6.1)
      railties (>= 4.2)
    websocket-driver (0.7.0)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.3)
    will_paginate (3.1.6)
    will_paginate-bootstrap (1.0.1)
      will_paginate (>= 3.0.3)

PLATFORMS
  ruby

DEPENDENCIES
  bootsnap (>= 1.1.0)
  camaleon_cms (>= 2.4.5)
  camaleon_post_order!
  capistrano (~> 3.11)
  capistrano-copy-files
  capose
  data_migrate
  draper (~> 3)
  factory_bot_rails
  faker (~> 1.9)
  listen (>= 3.0.5, < 3.2)
  overcommit
  pg (>= 0.18, < 2.0)
  pry
  pry-byebug
  pry-rails
  pry-stack_explorer
  puma (~> 3.11)
  rails (~> 5.2.2)
  rspec-rails (~> 3.8)
  rubocop
  seed_dump
  spring
  spring-commands-rspec
  spring-watcher-listen (~> 2.0.0)
  timecop
  uglifier (>= 1.3.0)
  web-console (>= 3.3.0)
  webpacker (~> 3.5)

RUBY VERSION
   ruby 2.5.3p105

BUNDLED WITH
   1.17.2

Version of postres:

❯ postgres --version
postgres (PostgreSQL) 10.5

This is the query that is running:


SELECT COUNT(DISTINCT "cama_posts"."id")
FROM "cama_posts"
       LEFT OUTER JOIN "cama_posts" "parents_cama_posts" ON "parents_cama_posts"."id" = "cama_posts"."post_parent"
    AND "parents_cama_posts"."post_class" = 'Post'
       LEFT OUTER JOIN "cama_term_taxonomy" ON "cama_term_taxonomy"."id" = "cama_posts"."taxonomy_id" AND
                                               "cama_term_taxonomy"."taxonomy" = 'post_type'
WHERE "cama_posts"."post_class" = 'Post'
  AND "cama_posts"."taxonomy_id" = 2
  AND (LOWER(cama_posts.title) LIKE '%abcd%' OR LOWER(cama_posts.slug LIKE '%abcd%'))
  AND "cama_posts"."status" = 'published'
mariusz-blaszczak commented 5 years ago

I prepared a fix: https://github.com/owen2345/camaleon-cms/pull/868 The problem was in closing parenthesis of PG LOWER func.

owen2345 commented 5 years ago

Thanks for the PR!

mariusz-blaszczak commented 5 years ago

@owen2345 can you release new patch version with the fix I provided. This way I could use your gem in my project instead of using my fork :)