Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError: undefined method `sort' #149

Open
Epigene opened this issue Feb 2, 2024 · 2 comments
Open

NoMethodError: undefined method `sort' #149

Epigene opened this issue Feb 2, 2024 · 2 comments

Comments

@Epigene
Copy link

Epigene commented Feb 2, 2024

Hi, I'm getting this error when running bundle exec rake db:find_indexes:

NoMethodError: undefined method `sort' for "lower((manufacturing_context)::text)":String (NoMethodError)

        index.columns.size > 1 ? index.columns.sort : index.columns.first
                                              ^^^^^
ruby-3.2.3/gems/lol_dba-2.4.0/lib/lol_dba/index_finding/index_finder.rb:61:in `block in table_indexes'
ruby-3.2.3/gems/lol_dba-2.4.0/lib/lol_dba/index_finding/index_finder.rb:60:in `collect'
ruby-3.2.3/gems/lol_dba-2.4.0/lib/lol_dba/index_finding/index_finder.rb:60:in `table_indexes'
ruby-3.2.3/gems/lol_dba-2.4.0/lib/lol_dba/index_finding/index_finder.rb:55:in `existing_indexes'
ruby-3.2.3/gems/lol_dba-2.4.0/lib/lol_dba/index_finding/index_finder.rb:44:in `block in missing_indexes'
ruby-3.2.3/gems/lol_dba-2.4.0/lib/lol_dba/index_finding/index_finder.rb:42:in `each'
ruby-3.2.3/gems/lol_dba-2.4.0/lib/lol_dba/index_finding/index_finder.rb:42:in `missing_indexes'
ruby-3.2.3/gems/lol_dba-2.4.0/lib/lol_dba/index_finding/index_finder.rb:37:in `check_for_indexes'
ruby-3.2.3/gems/lol_dba-2.4.0/lib/lol_dba/index_finding/index_finder.rb:4:in `run'
ruby-3.2.3/gems/lol_dba-2.4.0/lib/tasks/lol_dba.rake:6:in `block (2 levels) in <main>'
ruby-3.2.3/gems/bugsnag-6.26.0/lib/bugsnag/integrations/rake.rb:20:in `execute'
ruby-3.2.3/gems/rake-13.1.0/exe/rake:27:in `<top (required)>'
ruby-3.2.3/bin/ruby_executable_hooks:22:in `eval'
ruby-3.2.3/bin/ruby_executable_hooks:22:in `<main>'

This likely occurs because a synthetic index is defined:

CREATE INDEX idx_details_lower_manufacturing_context ON public.details USING btree (lower((manufacturing_context)::text));

My env:
Ruby 3.2.3
Rails: 7.0
Postgres: 15.5
lol_dba (2.4.0)

@h0jeZvgoxFepBQ2C
Copy link

Same here: NoMethodError: undefined method `sort' for "lower((code)::text), locked_at":String
Bildschirmfoto 2024-09-02 um 16 49 54

@h0jeZvgoxFepBQ2C
Copy link

Happens when you have a complex index

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants