-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
implement charset()
function
#2662
Conversation
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.
Looks good!
{ | ||
Query: "select charset(null)", | ||
Expected: []sql.Row{ | ||
{"binary"}, |
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.
weird that the docs say charset()
returns null
if the argument is null
. I also see my version of MySQL returning binary
here, so looks like MySQL's documentation is incorrect. 🤷🏻
sql/expression/function/collation.go
Outdated
@@ -144,3 +144,64 @@ func (c *Coercibility) Type() sql.Type { | |||
func (*Coercibility) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte) { | |||
return sql.Collation_binary, 5 | |||
} | |||
|
|||
// Charset is a function that returns the collation of the inner expression. |
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.
// Charset is a function that returns the collation of the inner expression. | |
// Charset is a function that returns the character set of the inner expression. |
sql/expression/function/collation.go
Outdated
if val == nil { | ||
return sql.CharacterSet_binary.Name(), nil | ||
} | ||
// Otherwise, we return the collation calculated from the expression |
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.
// Otherwise, we return the collation calculated from the expression | |
// Otherwise, we return the character set calculated from the expression |
MySQL Docs: https://dev.mysql.com/doc/refman/8.4/en/information-functions.html#function_charset