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

Throws error when using composite primary keys (supported natively by rails 7.1) #996

Open
mintuhouse opened this issue Oct 1, 2023 · 1 comment

Comments

@mintuhouse
Copy link
Contributor

Unable to annotate app/models/user_login_change_key.rb: comparison of Array with Array failed
        /bundle/ruby/3.2.0/bundler/gems/annotate_models-e60a66644e8a/lib/annotate/annotate_models.rb:367:in `sort_by'
        /bundle/ruby/3.2.0/bundler/gems/annotate_models-e60a66644e8a/lib/annotate/annotate_models.rb:367:in `get_foreign_key_info'
        /bundle/ruby/3.2.0/bundler/gems/annotate_models-e60a66644e8a/lib/annotate/annotate_models.rb:203:in `get_schema_info'
        /bundle/ruby/3.2.0/bundler/gems/annotate_models-e60a66644e8a/lib/annotate/annotate_models.rb:539:in `annotate'
        /bundle/ruby/3.2.0/bundler/gems/annotate_models-e60a66644e8a/lib/annotate/annotate_models.rb:740:in `annotate_model_file'
        /bundle/ruby/3.2.0/bundler/gems/annotate_models-e60a66644e8a/lib/annotate/annotate_models.rb:716:in `block in do_annotations'
        /bundle/ruby/3.2.0/bundler/gems/annotate_models-e60a66644e8a/lib/annotate/annotate_models.rb:715:in `each'
        /bundle/ruby/3.2.0/bundler/gems/annotate_models-e60a66644e8a/lib/annotate/annotate_models.rb:715:in `do_annotations'
        /bundle/ruby/3.2.0/bundler/gems/annotate_models-e60a66644e8a/bin/annotate:31:in `<top (required)>'
        /bundle/ruby/3.2.0/bin/annotate:25:in `load'
        /bundle/ruby/3.2.0/bin/annotate:25:in `<top (required)>'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:58:in `load'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:58:in `kernel_load'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:23:in `run'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/cli.rb:492:in `exec'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/cli.rb:34:in `dispatch'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/cli.rb:28:in `start'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/exe/bundle:37:in `block in <top (required)>'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/exe/bundle:29:in `<top (required)>'
        /railsapi/bin/bundle:108:in `load'
        /railsapi/bin/bundle:108:in `<main>'
Unable to annotate app/models/user_login_change_key.rb: no implicit conversion of nil into Array
        /bundle/ruby/3.2.0/bundler/gems/annotate_models-e60a66644e8a/lib/annotate/annotate_models.rb:740:in `concat'
        /bundle/ruby/3.2.0/bundler/gems/annotate_models-e60a66644e8a/lib/annotate/annotate_models.rb:740:in `annotate_model_file'
        /bundle/ruby/3.2.0/bundler/gems/annotate_models-e60a66644e8a/lib/annotate/annotate_models.rb:716:in `block in do_annotations'
        /bundle/ruby/3.2.0/bundler/gems/annotate_models-e60a66644e8a/lib/annotate/annotate_models.rb:715:in `each'
        /bundle/ruby/3.2.0/bundler/gems/annotate_models-e60a66644e8a/lib/annotate/annotate_models.rb:715:in `do_annotations'
        /bundle/ruby/3.2.0/bundler/gems/annotate_models-e60a66644e8a/bin/annotate:31:in `<top (required)>'
        /bundle/ruby/3.2.0/bin/annotate:25:in `load'
        /bundle/ruby/3.2.0/bin/annotate:25:in `<top (required)>'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:58:in `load'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:58:in `kernel_load'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:23:in `run'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/cli.rb:492:in `exec'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/cli.rb:34:in `dispatch'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/cli.rb:28:in `start'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/exe/bundle:37:in `block in <top (required)>'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
        /bundle/ruby/3.2.0/gems/bundler-2.4.19/exe/bundle:29:in `<top (required)>'
        /railsapi/bin/bundle:108:in `load'
        /railsapi/bin/bundle:108:in `<main>'

Version

  • annotate version: develop branch
  • rails version: 7.1.0.rc1
  • ruby version: 3.2.0
@mintuhouse
Copy link
Contributor Author

Options to fix

  1. Change show_complete_foreign_keys to true OR
  2. Change this line from foreign_keys.sort_by {|fk| [format_name.call(fk), fk.column]}.each do |fk| to foreign_keys.sort_by {|fk| [format_name.call(fk), *fk.column]}.each do |fk|

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

1 participant