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

The SchemaLoader raises an error on GitLab's schema.rb #200

Closed
pocke opened this issue Feb 18, 2020 · 0 comments · Fixed by #203
Closed

The SchemaLoader raises an error on GitLab's schema.rb #200

pocke opened this issue Feb 18, 2020 · 0 comments · Fixed by #203
Assignees
Labels
bug Something isn't working

Comments

@pocke
Copy link
Contributor

pocke commented Feb 18, 2020

I've added the schema loader in #197, but I found an error with GitLab's db/schema.rb.
I'll send a pull request as soon as possible, probably tonight.


Expected behavior

No errors during parsing db/schema.rb.

Actual behavior

An error occurred (at least).

Steps to reproduce the problem

$ git clone https://github.com/gitlabhq/gitlabhq
$ cd gitlabhq/
$ ruby -rparser/ruby26 -rrubocop-rails -e 'RuboCop::Rails::SchemaLoader.load 2.6'
/home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/parser-2.7.0.2/lib/parser/lexer.rb:10972: warning: assigned but unused variable - testEof
/home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader/schema.rb:134:in `build_columns': undefined method `values' for s(:str, "lower((extern_uid)::text), provider"):RuboCop::AST::StrNode (NoMethodError)
Did you mean?  value
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader/schema.rb:125:in `initialize'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader/schema.rb:75:in `new'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader/schema.rb:75:in `block in build_indices'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader/schema.rb:85:in `block in each_content'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader/schema.rb:84:in `each'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader/schema.rb:84:in `each_content'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader/schema.rb:71:in `each'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader/schema.rb:71:in `map'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader/schema.rb:71:in `build_indices'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader/schema.rb:52:in `initialize'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader/schema.rb:27:in `new'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader/schema.rb:27:in `block in build!'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader/schema.rb:37:in `block in each_table'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader/schema.rb:34:in `each'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader/schema.rb:34:in `each_table'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader/schema.rb:26:in `build!'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader/schema.rb:12:in `initialize'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader.rb:34:in `new'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader.rb:34:in `load!'
	from /home/pocke/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rubocop-rails-2.4.2/lib/rubocop/rails/schema_loader.rb:18:in `load'
	from -e:1:in `<main>'

The cause is the following line:

    t.index "lower((extern_uid)::text), provider", name: "index_on_identities_lower_extern_uid_and_provider"

https://github.com/gitlabhq/gitlabhq/blob/dc560bd238764df34382017e23f2667ade0c7a2d/db/schema.rb#L2017

RuboCop version

master branch.

@pocke pocke self-assigned this Feb 18, 2020
@pocke pocke added the bug Something isn't working label Feb 18, 2020
pocke added a commit to pocke/rubocop-rails that referenced this issue Feb 18, 2020
@koic koic closed this as completed in #203 Feb 20, 2020
koic added a commit that referenced this issue Feb 20, 2020
…ValidationWithoutIndex-cop

[Fix #200] Make SchemaLoader aware of Rails 5 expression index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant