Support default expression and expression indexes for MySQL #34307
Conversation
MySQL 8.0.13 and higher supports functional key parts that index expression 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 or expression. https://dev.mysql.com/doc/refman/8.0/en/create-table.html
lengths = options.delete(:lengths) | ||
|
||
columns = index[-2].map { |name| | ||
[ name.to_sym, expressions[name] || +quote_column_name(name) ] |
chrismaximin
Oct 25, 2018
Contributor
Why would we want to dup quote_column_name(name)
here?
Why would we want to dup quote_column_name(name)
here?
kamipo
Oct 25, 2018
Author
Member
This is because the quoted columns would be mutated by add_index_length
and add_index_sort_order
:
This is because the quoted columns would be mutated by add_index_length
and add_index_sort_order
:
chrismaximin
Oct 26, 2018
•
Contributor
Ah I see, I thought quote_column_name
would return something that was already duped somehow... because it is the case of
... but I didn't realise the method may always return the same object like ...
... 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.
Ah I see, I thought quote_column_name
would return something that was already duped somehow... because it is the case of
... but I didn't realise the method may always return the same object like ...
... 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.
chrismaximin
Oct 26, 2018
•
Contributor
Nevermind, I misread this whole thing 👍
Nevermind, I misread this whole thing
suketa
added a commit
to suketa/rails_sandbox
that referenced
this pull request
Jul 6, 2019
Support default expression and expression indexes for MySQL rails/rails#34307
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
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.