Skip to content

[Rails 6.1] Support different index types #1001

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

Closed

Conversation

aidanharan
Copy link
Contributor

@aidanharan aidanharan commented Feb 8, 2022

Fixes clustered index issue identified in #999

Now connection.add_index "testings", "last_name", type: :clustered will successfully generate the SQL to create the clustered index.

The issue was introduced between Rails 6.0 and 6.1 by rails/rails#39203

sql << "UNIQUE" if index.unique
sql << index.type if index.type
sql << "INDEX"
sql << o.algorithm if o.algorithm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQL Server does not support the algorithm option.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in PR to main in #1002

sql << o.algorithm if o.algorithm
sql << "#{quote_column_name(index.name)} ON #{quote_table_name(index.table)}"
sql << "(#{quoted_columns(index)})"
sql << "WHERE #{index.where}" if supports_partial_index? && index.where
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to check for supports_partial_index? here? We know SQL Server does support that already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in PR to main in #1002


#### Fixed

- [#999](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues/999) Fixed support for index types
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changelog should contain the link to the PR, not the issue itself. Also, if the issue is still present in Rails 6.1+, target branch must be main and changes should be backported to all previous versions that we still support.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in PR to main in #1002

@aidanharan
Copy link
Contributor Author

As @wpolicarpo said, the fix should have been made to main first and then back-ported to the 6-1-stable branch. I will close this PR and open a new one after #1002 is merged to main.

@aidanharan aidanharan closed this Feb 8, 2022
@wpolicarpo wpolicarpo removed their assignment Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants