mirror of
https://github.com/apache/superset.git
synced 2026-04-21 00:54:44 +00:00
fix: preventing sql lab None limit value (#17155)
* fix: preventing sql lab None limit value * test: create a test for the fix * pylint (#17172) * add test (#17173) Co-authored-by: Hugh A. Miles II <hughmil3s@gmail.com>
This commit is contained in:
@@ -44,6 +44,7 @@ from superset.sql_lab import (
|
||||
execute_sql_statement,
|
||||
get_sql_results,
|
||||
SqlLabException,
|
||||
apply_limit_if_exists,
|
||||
)
|
||||
from superset.sql_parse import CtasMethod
|
||||
from superset.utils.core import (
|
||||
@@ -990,6 +991,29 @@ class TestSqlLab(SupersetTestCase):
|
||||
]
|
||||
}
|
||||
|
||||
def test_apply_limit_if_exists_when_incremented_limit_is_none(self):
|
||||
sql = """
|
||||
SET @value = 42;
|
||||
SELECT @value AS foo;
|
||||
"""
|
||||
database = get_example_database()
|
||||
mock_query = mock.MagicMock()
|
||||
mock_query.limit = 300
|
||||
final_sql = apply_limit_if_exists(database, None, mock_query, sql)
|
||||
|
||||
assert final_sql == sql
|
||||
|
||||
def test_apply_limit_if_exists_when_increased_limit(self):
|
||||
sql = """
|
||||
SET @value = 42;
|
||||
SELECT @value AS foo;
|
||||
"""
|
||||
database = get_example_database()
|
||||
mock_query = mock.MagicMock()
|
||||
mock_query.limit = 300
|
||||
final_sql = apply_limit_if_exists(database, 1000, mock_query, sql)
|
||||
assert "LIMIT 1000" in final_sql
|
||||
|
||||
|
||||
@pytest.mark.parametrize("spec", [HiveEngineSpec, PrestoEngineSpec])
|
||||
def test_cancel_query_implicit(spec: BaseEngineSpec) -> None:
|
||||
|
||||
Reference in New Issue
Block a user