PoorMansTSqlFormatter
PoorMansTSqlFormatter copied to clipboard
USING clause in CONVERT function
MySQL supports a (purportedly SQL-standard?) USING
clause in the CONVERT
function: http://dev.mysql.com/doc/refman/5.7/en/charset-convert.html
Example:
SELECT convert(`somewhere`.`overtherainbow` using utf8)
FROM MyTable
Poor man's T-SQL formatter doesn't understand this, and instead identifies a bug/problem in the CONVERT arguments; there is no ill consequence, except the standard "WARNING! ERRORS ENCOUNTERED DURING SQL PARSING!" warning.
There is a workaround, which is to use the CAST syntax instead. In this syntax, MySQL does not reuse the "USING" keyword, which seems to be what is throwing the formatter off in the previous case:
SELECT CAST(`somewhere`.`overtherainbow` as char character set utf8)
FROM MyTable
This workaround may or may not be appealing, as it does require additional type information to be explicitly specified in the query.
PLEASE NOTE: if you do use this workaround, be sure to disable the "Keyword standardization" option, as this is option is only ever safe on Microsoft T-SQL code. In this case, for example, it would change the CHARACTER in CHARACTER SET to CHAR, making the syntax invalid.
Setting medium priority, as it's a bit of an edge case with workaround, but we're trying to give SQL dialect interoperability issues higher weight given the increased presence in linux-land with the npm packages.