[Mysql] small update to quote table names. Mysql 8 has keywords that… #512
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.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
… might match table names which cause an exception when selecting with the deleted/deleted at columns.
To reproduce the issue:
We have Rails model Group with its table name as 'groups'. It is related to another model/table Content/contents
We use mysql 8
Rails 6 (latest)
When we try to restore a record:
We get this error:
The issue with mysql 8 is 'groups' is now a reserved word. This is clashing with our table name. To overcome this the table name needs to quoted just like is done with the column name.
We are actually just expecting the record to be restored with its associations.
So this:
Here is a gist of the Gemfile.lock: https://gist.github.com/Kyle-Ferrara/593116e6af8170a2d99598946d459dec
There might be a better solution to this issue. This is what I could see. Feel free to take it or leave it lol.
I hope this will help guys using mysql 8.