-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
schemadiff
: assume default collation for textual column when collation is undefined
#16000
Changes from 3 commits
38bc519
e1c2b97
333c7f8
58983d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,7 +104,17 @@ func (c *ColumnDefinitionEntity) ColumnDiff( | |
) (*ModifyColumnDiff, error) { | ||
if c.IsTextual() || other.IsTextual() { | ||
// We will now denormalize the columns charset & collate as needed (if empty, populate from table.) | ||
|
||
// This column definition | ||
if c.columnDefinition.Type.Charset.Name != "" && c.columnDefinition.Type.Options.Collate == "" { | ||
collation := env.CollationEnv().DefaultCollationForCharset(c.columnDefinition.Type.Charset.Name) | ||
if collation == collations.Unknown { | ||
return nil, &UnknownColumnCharsetCollationError{Column: c.columnDefinition.Name.String(), Charset: t1cc.charset} | ||
} | ||
defer func() { | ||
c.columnDefinition.Type.Options.Collate = "" | ||
}() | ||
c.columnDefinition.Type.Options.Collate = env.CollationEnv().LookupName(collation) | ||
} | ||
if c.columnDefinition.Type.Charset.Name == "" && c.columnDefinition.Type.Options.Collate != "" { | ||
// Column has explicit collation but no charset. We can infer the charset from the collation. | ||
collationID := env.CollationEnv().LookupByName(c.columnDefinition.Type.Options.Collate) | ||
|
@@ -137,6 +147,17 @@ func (c *ColumnDefinitionEntity) ColumnDiff( | |
c.columnDefinition.Type.Options.Collate = env.CollationEnv().LookupName(collation) | ||
} | ||
} | ||
// other column definition | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see. So "this" and "other" are the two things being diffed. The other related comments are still worthwhile though IMO. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated this and other comments. |
||
if other.columnDefinition.Type.Charset.Name != "" && other.columnDefinition.Type.Options.Collate == "" { | ||
collation := env.CollationEnv().DefaultCollationForCharset(other.columnDefinition.Type.Charset.Name) | ||
if collation == collations.Unknown { | ||
return nil, &UnknownColumnCharsetCollationError{Column: other.columnDefinition.Name.String(), Charset: t2cc.charset} | ||
} | ||
defer func() { | ||
other.columnDefinition.Type.Options.Collate = "" | ||
}() | ||
other.columnDefinition.Type.Options.Collate = env.CollationEnv().LookupName(collation) | ||
} | ||
if other.columnDefinition.Type.Charset.Name == "" && other.columnDefinition.Type.Options.Collate != "" { | ||
// Column has explicit collation but no charset. We can infer the charset from the collation. | ||
collationID := env.CollationEnv().LookupByName(other.columnDefinition.Type.Options.Collate) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the full comment? 🙂 I'm assuming it should be ~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated this and other comments.