-
Notifications
You must be signed in to change notification settings - Fork 110
Conversation
Signed-off-by: bake <[email protected]>
Signed-off-by: bake <[email protected]>
if b.Len() == 0 { | ||
return "", nil | ||
} | ||
for i := len([]rune(b.String())); i < 4; i++ { |
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.
why 4 (because type rune = int32)?
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.
Even though the reference doesn't say so, MySQL returns at least four characters, if one of them is a letter:
mysql> select soundex('');
+-------------+
| soundex('') |
+-------------+
| |
+-------------+
1 row in set (0,00 sec)
mysql> select soundex('Q');
+--------------+
| soundex('Q') |
+--------------+
| Q000 |
+--------------+
1 row in set (0,00 sec)
mysql> select soundex('Quadratically');
+--------------------------+
| soundex('Quadratically') |
+--------------------------+
| Q36324 |
+--------------------------+
1 row in set (0,00 sec)
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 am not sure how close this should follow MySQL, since it is not a replacement. Always returning a string of 0 or 4 characters would be a possibility, too.
@kuba-- Should I change something? |
@bakerolls - could you rebase. Btw. I accepted this PR but to merge it we have to wait for a maintainer. |
Signed-off-by: bake <[email protected]> # Conflicts: # sql/expression/function/registry.go
Thank you! |
@bakerolls thanks for the contribution! |
This PR adds a soundex function as described in the MySQL Reference and implemented in mf_soundex.c in mysql/mysql-server.