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.
What did this pull request do?
In the issue #3973, if a struct with any composite indexes, these indexes will be invalid when the struct is embedded more than once. Because a composite index must specify its name, embedding more than once results in the duplicated name in db. Also if the name of index is specified manually,
NamingStrategy
will not be applied. Take the example of #3973:Both
Bar0
andBar1
will try to create an index of the same namemy_idx
. In this pull request, it provides a new field of index tag which is named tocomposite
. It means the id of composite index. All fields which have the same composite id of the struct are put together to the same index, just like the original rule. But the improvement is it lets the most derived/embedding struct generates the name of index byNamingStrategy
. For example:If the table
Foo
is created, the name of composite index will beidx_foo_myname
.Respectively, the name of composite index are
idx_bar0_myname
andidx_bar1_myname
.composite
only works if not specify the name of index, so it keeps the original API from being broken.