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

Add charset and collation options support for MySQL string and text columns. #17574

Merged
merged 1 commit into from
Apr 7, 2015

Conversation

kamipo
Copy link
Member

@kamipo kamipo commented Nov 10, 2014

MySQL is possible to specify charset and collation in each column.

This is useful to for a case-sensitive search or specify charset ascii to secret_token column.

Index size of string column depends on maxlen of that charset. In the case of strict_mode, it can be in error INSERT of characters that are not included in that charset.

@kamipo kamipo force-pushed the charset_collation_options branch 3 times, most recently from 919d69d to 2050cde Compare November 10, 2014 07:20

def initialize(name, default, cast_type, sql_type = nil, null = true, collation = nil, strict = false, extra = "")
@strict = strict
@collation = collation
@charset = collation.sub(/_.*\z/, '') unless collation.nil?
Copy link
Member

Choose a reason for hiding this comment

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

Why are we setting a default charset based on the collation?

Copy link
Member Author

Choose a reason for hiding this comment

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

Although I thought charset necessary for specify collation, was not that necessary.

@jeremy
Copy link
Member

jeremy commented Nov 10, 2014

👍 to the concept. This is a great way to reduce the size of large indexes on ascii columns.

@kamipo kamipo force-pushed the charset_collation_options branch 3 times, most recently from 35778da to 1070ef1 Compare November 15, 2014 06:23
@kamipo kamipo changed the title Add support for MySQL columns charset and collation options. Add charset and collation options support for MySQL string and text columns. Dec 2, 2014
@kamipo kamipo force-pushed the charset_collation_options branch 2 times, most recently from 813d1a2 to 2b2ff83 Compare December 4, 2014 02:05
@kamipo kamipo force-pushed the charset_collation_options branch 3 times, most recently from f5b2f69 to a8fc097 Compare December 16, 2014 09:43
@kamipo kamipo force-pushed the charset_collation_options branch 3 times, most recently from ddc0111 to 23cc2f6 Compare January 3, 2015 07:04
@kamipo kamipo force-pushed the charset_collation_options branch 2 times, most recently from 1c1a187 to f15532a Compare January 8, 2015 22:38
@kamipo kamipo force-pushed the charset_collation_options branch 3 times, most recently from 731f1a1 to 47ac3ef Compare February 24, 2015 16:39
…text columns

Example:

    create_table :foos do |t|
      t.string :string_utf8_bin, charset: 'utf8', collation: 'utf8_bin'
      t.text   :text_ascii,      charset: 'ascii'
    end
@kamipo kamipo force-pushed the charset_collation_options branch from 47ac3ef to 0aa83f3 Compare March 6, 2015 09:56
@jeremy jeremy merged commit 0aa83f3 into rails:master Apr 7, 2015
jeremy added a commit that referenced this pull request Apr 7, 2015
Add charset and collation options support for MySQL string and text columns.
@kamipo kamipo deleted the charset_collation_options branch April 7, 2015 17:37
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

Successfully merging this pull request may close these issues.

None yet

2 participants