Skip to content

include: option on add_index does nothing #1330

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
jlammers-mas opened this issue May 12, 2025 · 3 comments
Closed

include: option on add_index does nothing #1330

jlammers-mas opened this issue May 12, 2025 · 3 comments

Comments

@jlammers-mas
Copy link

The adapter seems to be able to derive included columns on an index during schema generation, but the add_index method "include:" option seems to do nothing. The adapter reports that it supports includes, but seems to only partially support it...

repro:

`class CreateSomeTable < ActiveRecord::Migration[8.0]
def change
create_table :some_table do |t|
t.varchar :field1, limit: 50
t.varchar :field2, limit: 50
t.varchar :field3, limit: 73

  t.timestamps
end
add_index :some_table, [ :field1, :field2], unique: true, include: :field3

end
end`

created a unique index on field1 and field2, but does not include field3

@aidanharan
Copy link
Contributor

aidanharan commented May 12, 2025

'INDEX INCLUDE' has been added to v8.1 of the adapter in #1301

It's not available in v8.0 so I'm not sure why the "adapter reports that it supports includes". Could you clarify?

Best way to clarify is to recreate the issue with a bug script. https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/How-to-report-a-bug

@jlammers-mas
Copy link
Author

I was specifically looking at this code from main:

If main is your 8.1 branch, then that may be my confusion.

@jlammers-mas
Copy link
Author

Ah - I see it is. Apologies...

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

No branches or pull requests

2 participants