fix: DB-specific quoting in Jinja macro (#25779)

This commit is contained in:
Beto Dealmeida
2023-10-30 09:50:44 -04:00
committed by GitHub
parent ed14f36c55
commit 5659c87ed2
2 changed files with 38 additions and 16 deletions

View File

@@ -20,17 +20,22 @@ import json
import pytest
from pytest_mock import MockFixture
from sqlalchemy.dialects import mysql
from superset.datasets.commands.exceptions import DatasetNotFoundError
from superset.jinja_context import dataset_macro, where_in
from superset.jinja_context import dataset_macro, WhereInMacro
def test_where_in() -> None:
"""
Test the ``where_in`` Jinja2 filter.
"""
where_in = WhereInMacro(mysql.dialect())
assert where_in([1, "b", 3]) == "(1, 'b', 3)"
assert where_in([1, "b", 3], '"') == '(1, "b", 3)'
assert where_in([1, "b", 3], '"') == (
"(1, 'b', 3)\n-- WARNING: the `mark` parameter was removed from the "
"`where_in` macro for security reasons\n"
)
assert where_in(["O'Malley's"]) == "('O''Malley''s')"