Closed jrieger closed 3 years ago
I had several problems trying to update this gem for Alchemy 4.1 and Rails 5.2:
PG::UndefinedColumn: ERROR: column alchemy_contents.searchable does not exist
if I search using the search pageI was able to solve the 1) commenting out these 3 lines (in fact avoid to search): https://github.com/AlchemyCMS/alchemy-pg_search/blob/master/lib/alchemy/pg_search/controller_methods.rb#L37
I don't know the reason to add a fake query param in the admin preview anyway.
For the 2) I commented out the lines: https://github.com/AlchemyCMS/alchemy-pg_search/blob/master/lib/alchemy/pg_search/page_extension.rb#L12 just to try to search only the pages, without the associations.
I got a different error:
Cannot have a has_many :through association 'Alchemy::Element#searchable_essence_texts' which goes through 'Alchemy::Element#contents' before the through association is defined.
I found that I was redefining the contents
association in my element_extension.rb in my app.
I commented also this (thus I don't know if it's a rails bug, I searched a bit, but I didn't get it).
After that, I had again the error:
PG::UndefinedColumn: ERROR: column alchemy_contents.searchable does not exist
in a different place, because of that:
https://github.com/AlchemyCMS/alchemy-pg_search/blob/master/lib/alchemy/pg_search/page_extension.rb#L43
I think the problem is to get the right associations for the searchable essences.
Both in the page_extension.rb
and in the element_extension.rb
, we are filtering the essences that are searchable and this query fails.
I spent yesterday afternoon to try to fix that, but I was not able to.
I tried to change this:
has_many :searchable_essence_texts,
-> { joins(:element).where(searchable: true, alchemy_elements: {public: true}) },
class_name: 'Alchemy::EssenceText',
source_type: 'Alchemy::EssenceText',
through: :contents,
source: :essence
but I never used the polymorphic associations, so I'm not sure what's going on here. This is the sql query:
SELECT 1 AS one
FROM "alchemy_elements"
INNER JOIN (SELECT "alchemy_elements"."id" AS pg_search_id, (ts_rank((to_tsvector('simple', coalesce(pg_search_668687a51782839efce5a1.pg_search_ce01f15def9367944d5461::text, ''))), (to_tsquery('simple', ''' ' || 'mirror' || ' ''' || ':*')), 0)) AS rank
FROM "alchemy_elements"
LEFT OUTER JOIN (SELECT "alchemy_elements"."id" AS id, string_agg("alchemy_essence_texts"."body"::text, ' ') AS pg_search_ce01f15def9367944d5461
FROM "alchemy_elements"
INNER JOIN "alchemy_contents" ON "alchemy_contents"."element_id" = "alchemy_elements"."id"
INNER JOIN "alchemy_contents" "contents_alchemy_essence_texts_join" ON "contents_alchemy_essence_texts_join"."essence_id" = "alchemy_contents"."id" AND "contents_alchemy_essence_texts_join"."essence_type" = 'Alchemy::EssenceText'
INNER JOIN "alchemy_elements" "elements_alchemy_essence_texts" ON "elements_alchemy_essence_texts"."id" = "contents_alchemy_essence_texts_join"."element_id" AND "alchemy_contents"."searchable" = TRUE AND "alchemy_elements"."public" = TRUE AND "alchemy_contents"."essence_type" = 'Alchemy::EssenceText'
INNER JOIN "alchemy_essence_texts" ON "alchemy_essence_texts"."id" =
"alchemy_contents"."essence_id"
INNER JOIN "alchemy_contents" "contents_alchemy_essence_texts_join" ON "contents_alchemy_essence_texts_join"."essence_id" = "alchemy_essence_texts"."id" AND "contents_alchemy_essence_texts_join"."essence_type" = 'Alchemy::EssenceText'
INNER JOIN "alchemy_elements" "elements_alchemy_essence_texts" ON "elements_alchemy_essence_texts"."id" = "contents_alchemy_essence_texts_join"."element_id" AND "alchemy_essence_texts"."searchable" = TRUE AND "alchemy_elements"."public" = TRUE
GROUP BY "alchemy_elements"."id") pg_search_668687a51782839efce5a1 ON pg_search_668687a51782839efce5a1.id = "alchemy_elements"."id"
WHERE (((to_tsvector('simple', coalesce(pg_search_668687a51782839efce5a1.pg_search_ce01f15def9367944d5461::text, ''))) @@ (to_tsquery('simple', ''' ' || 'mirror' || ' ''' || ':*'))))) AS pg_search_326f0a6e8c2e679dc4024c ON "alchemy_elements"."id" = pg_search_326f0a6e8c2e679dc4024c.pg_search_id
WHERE "alchemy_elements"."page_id" = $1 AND "alchemy_elements"."position" IS NOT NULL LIMIT $2
In my opinion, there's something weird here.
We have two times the filter for the searchable
column, one is wrong:
INNER JOIN "alchemy_elements" "elements_alchemy_essence_texts" ON "elements_alchemy_essence_texts"."id" = "contents_alchemy_essence_texts_join"."element_id" AND "alchemy_contents"."searchable" = TRUE AND "alchemy_elements"."public" = TRUE AND "alchemy_contents"."essence_type" = 'Alchemy::EssenceText'
and I don't know where it comes from. The second one is right:
INNER JOIN "alchemy_elements" "elements_alchemy_essence_texts" ON "elements_alchemy_essence_texts"."id" = "contents_alchemy_essence_texts_join"."element_id" AND "alchemy_essence_texts"."searchable" = TRUE AND "alchemy_elements"."public" = TRUE
The problem is that the first one comes first and raises the error.
@juryghidinelli I saw you have a repository where you used the pg_search gem. Maybe you could make a PR to port your work to this gem or may I do it? https://github.com/ArchimediaZerogroup/AlchemyBootstrapTemplate#pg-search
Alchemy 4 support would be awesome
I don't know the reason to add a fake query param in the admin preview anyway.
@afdev82 this is so that editors see how the page results look like in the edit page preview. This is a debatable feature and can be removed if it's causing too much trouble. 👍
2 )
This one is tricky. Don't know a quick solution now. But this looks like a load order issue. It seems that the contents
association is not present before the searchable associations get loaded.
Can you verify that this problem still exist in a fresh install?
@afdev82 I merged a fix for #1
Maybe worth trying again?
Yes, I will do some work on that soon.
In fact I was starting to implement the @juryghidinelli solution in my fork, but if there is an easier way, I would be glad to help.
I re-tried, but I got the same error. I'm using my custom branch (see https://github.com/adnotam/alchemy-pg_search/tree/custom), but updated to the latest master.
Gems included by the bundle:
* actioncable (5.2.1.1)
* actionmailer (5.2.1.1)
* actionpack (5.2.1.1)
* actionview (5.2.1.1)
* active_model_serializers (0.9.7)
* activejob (5.2.1.1)
* activemodel (5.2.1.1)
* activerecord (5.2.1.1)
* activerecord-session_store (1.1.1)
* activestorage (5.2.1.1)
* activesupport (5.2.1.1)
* acts_as_list (0.9.17)
* addressable (2.5.2)
* ahoy_email (1.0.2)
* ahoy_matey (2.1.0)
* airbrussh (1.3.1)
* alchemy-pg_search (1.2.0 bdb5831)
* alchemy_cms (4.1.0 c5cf9ba)
* alchemy_i18n (0.1.0 02d11ac)
* arel (9.0.0)
* ast (2.4.0)
* autoprefixer-rails (9.3.1)
* awesome_nested_set (3.1.4)
* base58 (0.2.3)
* bcrypt (3.1.12)
* bindex (0.5.0)
* brakeman (4.3.1)
* browser (2.5.3)
* builder (3.2.3)
* bullet (5.9.0)
* bundler (1.17.1)
* byebug (10.0.2)
* cancancan (2.3.0)
* capistrano (3.11.0)
* capistrano-bundler (1.4.0)
* capistrano-rails (1.4.0)
* capistrano-rbenv (2.1.4)
* capistrano-yarn (2.0.2)
* capistrano3-puma (3.1.1)
* capybara (3.12.0)
* capybara-screenshot (1.0.22)
* childprocess (0.9.0)
* coffee-rails (4.2.2)
* coffee-script (2.4.1)
* coffee-script-source (1.12.2)
* concurrent-ruby (1.1.3)
* countries (2.1.4)
* crack (0.4.3)
* crass (1.0.4)
* css_parser (1.6.0)
* dalli (2.7.9)
* device_detector (1.0.1)
* devise (4.5.0)
* devise-i18n (1.7.0)
* diff-lcs (1.3)
* docile (1.3.1)
* domain_name (0.5.20180417)
* dragonfly (1.2.0)
* dragonfly_svg (0.0.4)
* errbase (0.1.1)
* erubi (1.7.1)
* execjs (2.7.0)
* factory_bot (4.11.1)
* factory_bot_rails (4.11.1)
* faker (1.9.1)
* faraday (0.15.4)
* ffi (1.9.25)
* foundation_emails (2.2.1.0)
* geocoder (1.5.0)
* globalid (0.4.1)
* gutentag (2.4.0)
* handlebars_assets (0.23.2)
* hashdiff (0.3.7)
* hashie (3.5.7)
* highline (2.0.0)
* htmlentities (4.3.4)
* http-cookie (1.0.3)
* i18n (1.1.1)
* i18n-js (3.2.0)
* i18n-tasks (0.9.28)
* i18n_data (0.8.0)
* iniparse (1.4.4)
* inky-rb (1.3.7.3)
* inline_svg (1.3.1)
* jaro_winkler (1.5.1)
* jbuilder (2.8.0)
* jquery-rails (4.3.3)
* jquery-ui-rails (6.0.1)
* json (2.1.0)
* jwt (2.1.0)
* kaminari (1.1.1)
* kaminari-actionview (1.1.1)
* kaminari-activerecord (1.1.1)
* kaminari-core (1.1.1)
* launchy (2.4.3)
* letter_opener (1.6.0)
* libv8 (6.7.288.46.1)
* listen (3.1.5)
* loofah (2.2.3)
* mail (2.7.1)
* marcel (0.3.3)
* maxminddb (0.1.22)
* method_source (0.9.2)
* mime-types (3.2.2)
* mime-types-data (3.2018.0812)
* mimemagic (0.3.2)
* mini_mime (1.0.1)
* mini_portile (0.6.2)
* mini_portile2 (2.3.0)
* mini_racer (0.2.4)
* minitest (5.11.3)
* monetize (1.9.0)
* money (6.13.1)
* money-rails (1.13.0)
* mono_logger (1.1.0)
* multi_json (1.13.1)
* multi_xml (0.6.0)
* multipart-post (2.0.0)
* mustermann (1.0.3)
* net-scp (1.2.1)
* net-ssh (5.0.2)
* netrc (0.11.0)
* nilify_blanks (1.3.0)
* nio4r (2.3.1)
* nokogiri (1.8.5)
* non-stupid-digest-assets (1.0.9)
* nprogress-rails (0.2.0.2)
* oauth2 (1.4.1)
* omniauth (1.8.1)
* omniauth-oauth2 (1.5.0)
* originator (3.1)
* orm_adapter (0.5.0)
* overcommit (0.46.0)
* parallel (1.12.1)
* parser (2.5.3.0)
* pdf-core (0.7.0)
* pg (0.20.0)
* pg_search (2.1.2)
* phantomjs (2.1.1.0)
* powerpack (0.1.2)
* prawn (2.2.2)
* prawn-svg (0.28.0)
* prawn-table (0.2.2)
* prawn_rails (0.0.11)
* premailer (1.11.1)
* premailer-rails (1.10.2)
* public_suffix (3.0.3)
* puma (3.12.0)
* rack (2.0.6)
* rack-attack (5.4.2)
* rack-cache (1.8.0)
* rack-protection (2.0.4)
* rack-test (1.1.0)
* rack-tracker (1.7.0)
* rails (5.2.1.1)
* rails-controller-testing (1.0.2)
* rails-dom-testing (2.0.3)
* rails-html-sanitizer (1.0.4)
* rails-i18n (5.1.2)
* rails_real_favicon (0.0.11)
* railties (5.2.1.1)
* rainbow (3.0.0)
* rake (12.3.1)
* ransack (2.1.0)
* rb-fsevent (0.10.3)
* rb-inotify (0.9.10)
* redcarpet (3.4.0)
* redis (4.0.3)
* redis-namespace (1.6.0)
* referer-parser (0.3.0)
* regexp_parser (1.3.0)
* request_store (1.4.1)
* responders (2.4.0)
* resque (2.0.0)
* rest-client (2.0.2)
* rspec-core (3.8.0)
* rspec-expectations (3.8.2)
* rspec-mocks (3.8.0)
* rspec-rails (3.8.1)
* rspec-support (3.8.0)
* rubocop (0.60.0)
* rubocop-rspec (1.30.1)
* ruby-progressbar (1.10.0)
* ruby_dep (1.5.0)
* rubyzip (1.2.2)
* safe_yaml (1.0.4)
* safely_block (0.2.1)
* sassc (2.0.0)
* sassc-rails (2.0.0)
* select2-rails (3.5.10)
* shoulda-matchers (3.1.2)
* simple_form (4.1.0)
* simplecov (0.16.1)
* simplecov-html (0.10.2)
* sinatra (2.0.4)
* sixarm_ruby_unaccent (1.2.0)
* spring (2.0.2)
* spring-commands-rspec (1.0.4)
* spring-watcher-listen (2.0.1)
* sprockets (3.7.2)
* sprockets-rails (3.2.1)
* sshkit (1.18.0)
* terminal-table (1.8.0)
* thor (0.20.3)
* thread_safe (0.3.6)
* tilt (2.0.9)
* tiny_tds (0.7.0)
* ttfunk (1.5.1)
* turbolinks (5.2.0)
* turbolinks-source (5.2.0)
* tzinfo (1.2.5)
* uglifier (4.1.13)
* unf (0.1.4)
* unf_ext (0.0.7.5)
* unicode-display_width (1.4.0)
* unicode_utils (1.4.0)
* uniform_notifier (1.12.1)
* user_agent_parser (2.5.0)
* valid_email (0.1.2)
* vegas (0.1.11)
* warden (1.2.8)
* web-console (3.7.0)
* webmock (3.4.2)
* websocket-driver (0.7.0)
* websocket-extensions (0.1.3)
* wice_grid (4.1.0 885dda4)
* xpath (3.2.0)
@afdev82 I merged a fix for #1
Maybe worth trying again?
This is the stack trace:
NoMethodError (undefined method `page' for #<Ransack::Search:0x00007fad63b89648>):
ransack (2.1.0) lib/ransack/search.rb:106:in `method_missing'
/home/antonio/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/alchemy-pg_search-bdb5831e1f42/lib/alchemy/pg_search/controller_methods.rb:43:in `perform_search'
activesupport (5.2.1.1) lib/active_support/callbacks.rb:426:in `block in make_lambda'
activesupport (5.2.1.1) lib/active_support/callbacks.rb:179:in `block (2 levels) in halting_and_conditional'
actionpack (5.2.1.1) lib/abstract_controller/callbacks.rb:34:in `block (2 levels) in <module:Callbacks>'
activesupport (5.2.1.1) lib/active_support/callbacks.rb:180:in `block in halting_and_conditional'
activesupport (5.2.1.1) lib/active_support/callbacks.rb:513:in `block in invoke_before'
activesupport (5.2.1.1) lib/active_support/callbacks.rb:513:in `each'
activesupport (5.2.1.1) lib/active_support/callbacks.rb:513:in `invoke_before'
activesupport (5.2.1.1) lib/active_support/callbacks.rb:131:in `run_callbacks'
actionpack (5.2.1.1) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (5.2.1.1) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (5.2.1.1) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (5.2.1.1) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.1.1) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.1.1) lib/active_support/notifications.rb:168:in `instrument'
actionpack (5.2.1.1) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (5.2.1.1) lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
activerecord (5.2.1.1) lib/active_record/railties/controller_runtime.rb:24:in `process_action'
actionpack (5.2.1.1) lib/abstract_controller/base.rb:134:in `process'
actionview (5.2.1.1) lib/action_view/rendering.rb:32:in `process'
actionpack (5.2.1.1) lib/action_controller/metal.rb:191:in `dispatch'
actionpack (5.2.1.1) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (5.2.1.1) lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
actionpack (5.2.1.1) lib/action_dispatch/routing/route_set.rb:34:in `serve'
actionpack (5.2.1.1) lib/action_dispatch/journey/router.rb:52:in `block in serve'
actionpack (5.2.1.1) lib/action_dispatch/journey/router.rb:35:in `each'
actionpack (5.2.1.1) lib/action_dispatch/journey/router.rb:35:in `serve'
actionpack (5.2.1.1) lib/action_dispatch/routing/route_set.rb:840:in `call'
railties (5.2.1.1) lib/rails/engine.rb:524:in `call'
railties (5.2.1.1) lib/rails/railtie.rb:190:in `public_send'
railties (5.2.1.1) lib/rails/railtie.rb:190:in `method_missing'
actionpack (5.2.1.1) lib/action_dispatch/routing/mapper.rb:19:in `block in <class:Constraints>'
actionpack (5.2.1.1) lib/action_dispatch/routing/mapper.rb:48:in `serve'
actionpack (5.2.1.1) lib/action_dispatch/journey/router.rb:52:in `block in serve'
actionpack (5.2.1.1) lib/action_dispatch/journey/router.rb:35:in `each'
actionpack (5.2.1.1) lib/action_dispatch/journey/router.rb:35:in `serve'
actionpack (5.2.1.1) lib/action_dispatch/routing/route_set.rb:840:in `call'
omniauth (1.8.1) lib/omniauth/strategy.rb:190:in `call!'
omniauth (1.8.1) lib/omniauth/strategy.rb:168:in `call'
dragonfly (1.2.0) lib/dragonfly/middleware.rb:14:in `call'
dragonfly (1.2.0) lib/dragonfly/middleware.rb:14:in `call'
bullet (5.9.0) lib/bullet/rack.rb:15:in `call'
i18n-js (3.2.0) lib/i18n/js/middleware.rb:14:in `call'
rack-attack (5.4.2) lib/rack/attack.rb:175:in `call'
warden (1.2.8) lib/warden/manager.rb:36:in `block in call'
warden (1.2.8) lib/warden/manager.rb:34:in `catch'
warden (1.2.8) lib/warden/manager.rb:34: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.1.1) 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.1.1) lib/action_dispatch/middleware/cookies.rb:670:in `call'
activerecord (5.2.1.1) lib/active_record/migration.rb:559:in `call'
actionpack (5.2.1.1) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (5.2.1.1) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (5.2.1.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (5.2.1.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.1.1) 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.1.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.1.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.1.1) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.1.1) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.1.1) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.1.1) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.1.1) lib/rails/rack/logger.rb:26:in `call'
ahoy_matey (2.1.0) lib/ahoy/engine.rb:20:in `call_with_quiet_ahoy'
actionpack (5.2.1.1) 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.1.1) 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.1.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
dragonfly (1.2.0) lib/dragonfly/cookie_monster.rb:9:in `call'
actionpack (5.2.1.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.1.1) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.6) lib/rack/sendfile.rb:111:in `call'
railties (5.2.1.1) lib/rails/engine.rb:524:in `call'
/usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:97:in `process_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:149:in `accept_and_process_next_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:110:in `main_loop'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:415:in `block (3 levels) in start_threads'
/usr/lib/ruby/vendor_ruby/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception'
Started POST "/__web_console/repl_sessions/d25aea0012c51f98f7443417f10e4976/trace" for 127.0.0.1 at 2018-11-29 13:21:56 +0100
Started POST "/__web_console/repl_sessions/d25aea0012c51f98f7443417f10e4976/trace" for 127.0.0.1 at 2018-11-29 13:22:11 +0100
It works, I was redefining the method search_results
in my app.
Yes, the error is still there :( I'm using this dummy app: https://github.com/adnotam/dummy_cms_app It's a fresh install of Rails, with Alchemy 4, Alchemy Devise and my branch for the pg_search (https://github.com/adnotam/alchemy-pg_search/tree/alchemy_4)
Can you verify that this problem still exist in a fresh install?
I opened an issue for the pg_search
gem: https://github.com/Casecommons/pg_search/issues/392
@afdev82 stupid question but have you run the migrations?
bin/rake alchemy_pg_search:install:migrations
Yes, the migrations add the searchable
column to the essences, not to the alchemy_contents
table.
I think the problem is how the query gets created by pg_search
, but I don't know how to solve this.
I found the code that is failing in the pg_search
gem: https://github.com/Casecommons/pg_search/issues/392#issuecomment-444083315
Maybe this is not a bug in this gem, it's a bug of ActiveRecord.
I filled in an issue in Rails: https://github.com/rails/rails/issues/34613
I downgraded the rails version to be the latest of 5.0, currently 5.0.7.1
and I got another error:
PG::InvalidTextRepresentation: ERROR: invalid input syntax for type boolean: "Alchemy::EssenceText"
LINE 1: ...ce_id" AND "alchemy_essence_texts"."searchable" = 'Alchemy::...
^
: SELECT COUNT(*) FROM "alchemy_elements" INNER JOIN (SELECT "alchemy_elements"."id" AS pg_search_id, (ts_rank((to_tsvector('simple', coalesce(pg_search_668687a51782839efce5a1.pg_search_ce01f15def9367944d5461::text, '')) || to_tsvector('simple', coalesce(pg_search_0ab5bdc8ef47d219371cee.pg_search_c2a024eaf8093358eb47a3::text, '')) || to_tsvector('simple', coalesce(pg_search_04aa0b88403779d4b290e6.pg_search_a178105f545151136ec456::text, ''))), (to_tsquery('simple', ''' ' || 'mirror' || ' ''' || ':*')), 0)) AS rank FROM "alchemy_elements" LEFT OUTER JOIN (SELECT "alchemy_elements"."id" AS id, string_agg("alchemy_essence_texts"."body"::text, ' ') AS pg_search_ce01f15def9367944d5461 FROM "alchemy_elements" INNER JOIN "alchemy_contents" ON "alchemy_contents"."element_id" = "alchemy_elements"."id" AND "alchemy_contents"."essence_type" = 'Alchemy::EssenceText' INNER JOIN "alchemy_essence_texts" ON "alchemy_essence_texts"."id" = "alchemy_contents"."essence_id" AND "alchemy_essence_texts"."searchable" = 'Alchemy::EssenceText' AND "alchemy_elements"."public" = 't' GROUP BY "alchemy_elements"."id") pg_search_668687a51782839efce5a1 ON pg_search_668687a51782839efce5a1.id = "alchemy_elements"."id" LEFT OUTER JOIN (SELECT "alchemy_elements"."id" AS id, string_agg("alchemy_essence_richtexts"."stripped_body"::text, ' ') AS pg_search_c2a024eaf8093358eb47a3 FROM "alchemy_elements" INNER JOIN "alchemy_contents" ON "alchemy_contents"."element_id" = "alchemy_elements"."id" AND "alchemy_contents"."essence_type" = 'Alchemy::EssenceRichtext' INNER JOIN "alchemy_essence_richtexts" ON "alchemy_essence_richtexts"."id" = "alchemy_contents"."essence_id" AND "alchemy_essence_richtexts"."searchable" = 'Alchemy::EssenceRichtext' AND "alchemy_elements"."public" = 't' GROUP BY "alchemy_elements"."id") pg_search_0ab5bdc8ef47d219371cee ON pg_search_0ab5bdc8ef47d219371cee.id = "alchemy_elements"."id" LEFT OUTER JOIN (SELECT "alchemy_elements"."id" AS id, string_agg("alchemy_essence_pictures"."caption"::text, ' ') AS pg_search_a178105f545151136ec456 FROM "alchemy_elements" INNER JOIN "alchemy_contents" ON "alchemy_contents"."element_id" = "alchemy_elements"."id" AND "alchemy_contents"."essence_type" = 'Alchemy::EssencePicture' INNER JOIN "alchemy_essence_pictures" ON "alchemy_essence_pictures"."id" = "alchemy_contents"."essence_id" AND "alchemy_essence_pictures"."searchable" = 'Alchemy::EssencePicture' AND "alchemy_elements"."public" = 't' GROUP BY "alchemy_elements"."id") pg_search_04aa0b88403779d4b290e6 ON pg_search_04aa0b88403779d4b290e6.id = "alchemy_elements"."id" WHERE (((to_tsvector('simple', coalesce(pg_search_668687a51782839efce5a1.pg_search_ce01f15def9367944d5461::text, '')) || to_tsvector('simple', coalesce(pg_search_0ab5bdc8ef47d219371cee.pg_search_c2a024eaf8093358eb47a3::text, '')) || to_tsvector('simple', coalesce(pg_search_04aa0b88403779d4b290e6.pg_search_a178105f545151136ec456::text, ''))) @@ (to_tsquery('simple', ''' ' || 'mirror' || ' ''' || ':*'))))) AS pg_search_326f0a6e8c2e679dc4024c ON "alchemy_elements"."id" = pg_search_326f0a6e8c2e679dc4024c.pg_search_id WHERE "alchemy_elements"."page_id" = $1 AND ("alchemy_elements"."position" IS NOT NULL)
I found out that this time the error was related to the associations on the Alchemy::Element
class.
Eg: https://github.com/AlchemyCMS/alchemy-pg_search/blob/master/lib/alchemy/pg_search/element_extension.rb#L15
If I use includes(:element)
instead of joins(:element)
it works. Even if I remove it, it works.
I don't know if this is another bug in ActiveRecord or it should be like this.
After this fix (I will include that in the https://github.com/AlchemyCMS/alchemy-pg_search/pull/17), I think the gem should work at least in Rails 5.0. I tried that in my app and it worked.
@afdev82 Where are you at on this? I'm currently working on upgrading an app that's been on Alchemy 3.6. I had been depending on this gem. Do you have it working on any 4.x versions? I have a feeling I'll need to do some more work to get it up to 5.1 if possible, but I'd like to avoid repeating any work you've already done.
Hi @dbwinger , I opened a PR and also an issue in Rails, now there is another one opened. Anyway I'm not using the search functionality anymore, so I don't know if it will work with v5.1.
Done in #18
Are there any plans to make this gem compatible with Alchemy 4?