mirror of
https://github.com/apache/superset.git
synced 2026-09-01 13:01:33 +00:00
fix(sql): handle ORDER BY in embedded MSSQL queries (#43127)
Co-authored-by: Bexultan Mustafin <bexultan.mustafin@ffins.kz> Co-authored-by: Amin Ghadersohi <amin.ghadersohi@gmail.com>
This commit is contained in:
co-authored by
Bexultan Mustafin
Amin Ghadersohi
parent
856599027a
commit
1e65d93a83
@@ -2824,6 +2824,22 @@ def test_as_cte_called_twice() -> None:
|
||||
stmt.as_cte()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("sql", "removed"),
|
||||
[
|
||||
("SELECT value FROM source ORDER BY value", True),
|
||||
("SELECT TOP 1 value FROM source ORDER BY value", False),
|
||||
("SELECT value FROM source ORDER BY value OFFSET 0 ROWS", False),
|
||||
("SELECT value FROM source ORDER BY value FOR JSON AUTO", False),
|
||||
],
|
||||
)
|
||||
def test_remove_unbounded_top_level_order_by(sql: str, removed: bool) -> None:
|
||||
statement = SQLStatement(sql, "mssql")
|
||||
|
||||
assert statement.remove_unbounded_top_level_order_by() is removed
|
||||
assert ("ORDER BY" not in statement.format()) is removed
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"sql, rules, expected",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user