Description
When transpiling a SQL query from PostgreSQL dialect to MySQL dialect using polyglot_sql.transpile, the string concatenation operator || is incorrectly converted to the logical OR operator. This leads to semantically incorrect SQL.
Reproducible Example
Below is a Python code snippet that demonstrates the issue. The expected output for MySQL should use the CONCAT function, but polyglot-sql produces OR instead.
import polyglot_sql
polyglot_sql.transpile("SELECT 'A' || 'B'", read="postgres", write="mysql") # ["SELECT 'A' OR 'B'"]
# And generate
ast = polyglot_sql.parse_one("SELECT 'A' || 'B'", dialect="postgres")
polyglot_sql.generate(ast, dialect="mysql") # ["SELECT 'A' || 'B'"]
Expected Behavior
The correct transpilation from PostgreSQL's || (string concatenation) to MySQL should result in the use of the CONCAT() function.
Comparison with sqlglot
import sqlglot
sqlglot.transpile("SELECT 'A' || 'B'", read="postgres", write="mysql") # ["SELECT CONCAT('A', 'B')"]
Suggested Fix
Ensure that the PostgreSQL string concatenation operator || is correctly mapped to MySQL's CONCAT() function during transpilation within polyglot-sql.
Description
When transpiling a SQL query from PostgreSQL dialect to MySQL dialect using
polyglot_sql.transpile, the string concatenation operator||is incorrectly converted to the logicalORoperator. This leads to semantically incorrect SQL.Reproducible Example
Below is a Python code snippet that demonstrates the issue. The expected output for MySQL should use the
CONCATfunction, butpolyglot-sqlproducesORinstead.Expected Behavior
The correct transpilation from PostgreSQL's
||(string concatenation) to MySQL should result in the use of theCONCAT()function.Comparison with
sqlglotSuggested Fix
Ensure that the PostgreSQL string concatenation operator
||is correctly mapped to MySQL'sCONCAT()function during transpilation withinpolyglot-sql.