betodealmeida commented on code in PR #36136: URL: https://github.com/apache/superset/pull/36136#discussion_r2557849698
########## tests/unit_tests/sql/transpile_to_dialect_test.py: ########## @@ -0,0 +1,347 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +""" +Tests for transpile_to_dialect function in superset/sql/parse.py +""" + +import pytest + +from superset.sql.parse import transpile_to_dialect + + [email protected]( + "sql,dialect,expected", + [ + # PostgreSQL - SQL-92 standard double single quotes + ("name = 'O''Hara'", "postgresql", "name = 'O''Hara'"), + # MySQL - SQL-92 standard double single quotes + ("name = 'O''Hara'", "mysql", "name = 'O''Hara'"), + # SQLite - SQL-92 standard double single quotes + ("name = 'O''Hara'", "sqlite", "name = 'O''Hara'"), + # Snowflake - backslash escaping + ("name = 'O''Hara'", "snowflake", "name = 'O\\'Hara'"), Review Comment: Small nit, you can use `r"` strings to make this easier to read: ```suggestion ("name = 'O''Hara'", "snowflake", r"name = 'O\'Hara'"), ``` ########## tests/unit_tests/sql/transpile_to_dialect_test.py: ########## @@ -0,0 +1,347 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +""" +Tests for transpile_to_dialect function in superset/sql/parse.py +""" + +import pytest + +from superset.sql.parse import transpile_to_dialect + + [email protected]( + "sql,dialect,expected", + [ + # PostgreSQL - SQL-92 standard double single quotes + ("name = 'O''Hara'", "postgresql", "name = 'O''Hara'"), + # MySQL - SQL-92 standard double single quotes + ("name = 'O''Hara'", "mysql", "name = 'O''Hara'"), + # SQLite - SQL-92 standard double single quotes + ("name = 'O''Hara'", "sqlite", "name = 'O''Hara'"), + # Snowflake - backslash escaping + ("name = 'O''Hara'", "snowflake", "name = 'O\\'Hara'"), Review Comment: Small nit, you can use `r"` strings here and in other places to make it easier to read: ```suggestion ("name = 'O''Hara'", "snowflake", r"name = 'O\'Hara'"), ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
