Skip to content

Comments

Additional index type support#6101

Closed
MSNexploder wants to merge 6 commits intorails:masterfrom
MSNexploder:additional_index_support
Closed

Additional index type support#6101
MSNexploder wants to merge 6 commits intorails:masterfrom
MSNexploder:additional_index_support

Conversation

@MSNexploder
Copy link
Contributor

Added add_index override in postgresql_adapter and mysql_adapters to allow custom index type support.

add_index(:wikis, :body, :method => 'gin')

It's basically an updated version of this older pull request

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not overly excited about this, but the syntax differs too much to apply this directly in the abstract adapter. :-(

@gazay
Copy link
Contributor

gazay commented May 2, 2012

nice! 👍

@steveklabnik
Copy link
Member

This will need a rebase, but I know lots of people (like @schneems and @tenderlove) are pumped about supporting specific postgres types.

Copy link
Member

Choose a reason for hiding this comment

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

I prefer

options.is_a? Hash

over

Hash === options

would also maybe change options[:method] => options[:method].blank? to protect against anyone using an empty string

Copy link
Member

Choose a reason for hiding this comment

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

I agree about options.is_a? Hash, but I disagree about the check for blank?. I don't think we need to be so defensive.

@schneems
Copy link
Member

I'm 👍 for this feature, being able to specify types of indexes is nice definitely better than having to go in and write it manually:

  def up
    execute "CREATE INDEX products_gin_data ON products USING GIN(data)"
  end

  def down
    execute "DROP INDEX products_gin_data"
  end

I made a comment on code style, do you think you could fix that up, rebase this code, and we can get someone from ActiveRecord to take a look?

@kbrock
Copy link
Contributor

kbrock commented Oct 2, 2012

Object#method(name) is defined.

When trying to backport this to rails 3.2 it gave me a little grief.

Can we pick a different name for it?

The documentation seems to call it index_type for both postgres and my sql. While I don't like having the word index twice (IndexDefinition#index_type), it is more rails friendly than overriding Object#method.

Unfortunately, the create index code currently uses an index_type variable to specify unique. IndexDefinition uses 'unique' for this purpose, so it is only a local variable in 2 places. But a side note none the less

Thoughts?

@rafaelfranca
Copy link
Member

@kbrock Maybe just type?

@kbrock
Copy link
Contributor

kbrock commented Oct 3, 2012

Heh, type sounds good. I wasn't sure if that was too vague. I'm probably overt hinking this

I notice in the mysql code, it is called :Index_type (with an uppercase i)


So, what is needed to push this forward?

@rafaelfranca
Copy link
Member

@MSNexploder could you change to :type?

@MSNexploder
Copy link
Contributor Author

Totally forgot about this pull request...
Sure, I will look into it. :)

Conflicts:
	activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@tbaba
Copy link
Contributor

tbaba commented Nov 9, 2012

👍 I want this feature to use Trigram full text search on postgresql.

@jeremy
Copy link
Member

jeremy commented Nov 16, 2012

Perhaps this should be a :using option to mirror the SQL syntax.

@steveklabnik
Copy link
Member

@MSNexploder this will need to be squashed, and a CHANGELOG entry added.

@rafaelfranca
Copy link
Member

Closed in favor of #9451

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.

8 participants