Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support default expression and expression indexes for MySQL#34307

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kamipo merged 2 commits intorails:masterfromkamipo:mysql_expression_support
Oct 26, 2018

Conversation

@kamipo
Copy link
Member

MySQL 8.0.13 is released a few days ago.

https://mysqlserverteam.com/the-mysql-8-0-13-maintenance-release-is-generally-available/

Now we can supports default expression and expression indexes for mysql2 adapter.

jeremy and bogdanvlviv reacted with hooray emojiyahonda reacted with heart emoji
MySQL 8.0.13 and higher supports functional key parts that indexexpression values rather than column or column prefix values.https://dev.mysql.com/doc/refman/8.0/en/create-index.html
MySQL 8.0.13 and higher supports default value to be a function orexpression.https://dev.mysql.com/doc/refman/8.0/en/create-table.html
@kamipokamipoforce-pushed themysql_expression_support branch from1ac65ef toa2ad8f4CompareOctober 25, 2018 09:14
lengths=options.delete(:lengths)

columns=index[-2].map{ |name|
[name.to_sym,expressions[name] || +quote_column_name(name)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why would we want to dupquote_column_name(name) here?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

This is because the quoted columns would be mutated byadd_index_length andadd_index_sort_order:

defadd_index_length(quoted_columns, **options)
lengths=options_for_index_columns(options[:length])
quoted_columns.eachdo |name,column|
column <<"(#{lengths[name]})"iflengths[name].present?

defadd_index_sort_order(quoted_columns, **options)
orders=options_for_index_columns(options[:order])
quoted_columns.eachdo |name,column|
column <<"#{orders[name].upcase}"iforders[name].present?

chrismaximin reacted with thumbs up emoji
Copy link
Contributor

@chrismaximinchrismaximinOct 26, 2018
edited
Loading

Choose a reason for hiding this comment

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

Ah I see, I thoughtquote_column_name would return something that was already duped somehow... because it is the case of

defquote_column_name(column_name)
column_name.to_s
end

... but I didn't realise the method may always return the same object like ...
defquote_column_name(name)
@quoted_column_names[name] ||="`#{super.gsub('`','``')}`"
end

... got it :)

I'm just realising that there's no way (AFAIK) to know whether a method returns an object that is referenced elsewhere or not, which is kind of sad, because we may be duplicating strings for no reason (if a method returns a new object or an existing object), maybe we should do something about that one day.

Copy link
Contributor

@chrismaximinchrismaximinOct 26, 2018
edited
Loading

Choose a reason for hiding this comment

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

Nevermind, I misread this whole thing 👍

@kamipokamipo merged commit9e9e2b7 intorails:masterOct 26, 2018
@kamipokamipo deleted the mysql_expression_support branchOctober 26, 2018 09:51
suketa added a commit to suketa/rails_sandbox that referenced this pull requestJul 6, 2019
Support default expression and expression indexes for MySQLrails/rails#34307
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@chrismaximinchrismaximinchrismaximin left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@kamipo@chrismaximin

[8]ページ先頭

©2009-2025 Movatter.jp