Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #4853 (new defect)

Opened 2 years ago

Last modified 2 years ago

[PATCH] [TEST too!] activerecord has no support for subkey length in index definitions

Reported by: rubyonrails.org@troja.ath.cx Assigned to: David
Priority: normal Milestone:
Component: ActiveRecord Version:
Severity: normal Keywords: ActiveRecord, MySQL, PostgreSQL, INDEX, subkey
Cc:

Description

In for example MySQL you must set subkey length when you create an index that includes a TEXT or BLOB column:

CREATE INDEX users_text_column_index ON users (text_column(20));

In for example PostgreSQL you dont have to:

CREATE INDEX users_text_column_index ON users (text_column);

If you use MySQL and still want to use TEXT or BLOB columns in your index you cant use rails own schema definition language, or at least not with a lot of hassle.

Therefore I created this little patch, try it out and see if it fits :)

(I have not tested it as a patch! I have only created a plugin that does the same thing, and it works beautifully. Then I wanted to share it with the rest of the rails community, so I just copied the code to a fresh svn checkout and hoped for the best. If you absolutely wont test it yourself without me having tested it in this form beforehand, then Ill do it, though I bet you want to test it yourselves before accepting it anyway :)

Attachments

index_definition_patch.diff (4.8 kB) - added by rubyonrails.org@troja.ath.cx on 04/23/06 09:45:45.
a patch that makes rails understand subkey lengths in indexes
mysql_key_length.df (6.0 kB) - added by martin.kihlgren@adocca.com on 05/18/06 07:33:30.
the new and improved patch!

Change History

04/23/06 09:45:45 changed by rubyonrails.org@troja.ath.cx

  • attachment index_definition_patch.diff added.

a patch that makes rails understand subkey lengths in indexes

04/23/06 09:47:22 changed by rubyonrails.org@troja.ath.cx

s/with a lot of hassle/without a lot of hassle/

05/18/06 07:33:03 changed by martin.kihlgren@adocca.com

  • summary changed from [PATCH] activerecord has no support for subkey length in index definitions to [PATCH] [TEST too!] activerecord has no support for subkey length in index definitions.

I will submit a better patch against REV 4347 that not only fixes the problem AND passes the tests, it even has a test for the new functionality! :)

05/18/06 07:33:30 changed by martin.kihlgren@adocca.com

  • attachment mysql_key_length.df added.

the new and improved patch!