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

False negative Sequel/ConcurrentIndex in some cases. Ignores options passed in hash. #15

Open
PapevisO opened this issue Nov 17, 2020 · 1 comment

Comments

@PapevisO
Copy link

Ignores options passed in an options hash along with gin_trgm_ops relevant with pg_trgm extension.
This way concurrently: true, though provided, is not detected by linter.

Sequel.migration do
  no_transaction

  up do
    DB.execute('CREATE EXTENSION IF NOT EXISTS pg_trgm;')
    alter_table(:foos) do
      opts = {
        name: :foos_bar_search_index,
        type: :gin,
        concurrently: true
      }
      add_index(Sequel.lit(" gin_trgm_ops"), opts)
    end
  end
end

Issue produced with the following version

GIT
  remote: git://github.com/rubocop-hq/rubocop-sequel.git
  revision: 99fc07d33c6dd4a2b38627316764ab2cc7ce750c
  ref: 99fc07d33c6dd4a2b38627316764ab2cc7ce750c
  specs:
    rubocop-sequel (0.1.0)
      rubocop (~> 1.0)
@jvanderen1
Copy link

This is affecting our codebase as well. Folks have accidentally used ActiveRecord's algorithm: :concurrently in our codebae and no error was thrown by either rubocop-sequel or sequel.

Example:

Sequel.migration do
  no_transaction
  change do
    alter_table :foo do
      add_index :bar_id                           # ✅ `convention:Sequel/ConcurrentIndex` error thrown
      add_index :baz_id, concurrently: true       # ✅ No error thrown
      add_index :qux_id, algorithm: :concurrently # ❌ No error thrown
    end
  end
end

We should have better typing / linting for the options passed into the migration method

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