Test _query_includes_limit function.
()
| 396 | |
| 397 | @pytest.mark.skipif(not HAS_SQLGLOT, reason="sqlglot not installed") |
| 398 | def test_query_includes_limit() -> None: |
| 399 | """Test _query_includes_limit function.""" |
| 400 | # Test queries with LIMIT |
| 401 | assert _query_includes_limit("SELECT * FROM table LIMIT 5") |
| 402 | assert _query_includes_limit("SELECT * FROM table LIMIT\n5") |
| 403 | assert _query_includes_limit("SELECT * FROM table limit\n5") |
| 404 | assert _query_includes_limit( |
| 405 | """ |
| 406 | SELECT * |
| 407 | FROM table |
| 408 | LIMIT 5 |
| 409 | """ |
| 410 | ) |
| 411 | |
| 412 | # Test queries without LIMIT |
| 413 | assert not _query_includes_limit("SELECT * FROM table") |
| 414 | assert not _query_includes_limit("SELECT LIMIT_COL FROM table") |
| 415 | assert not _query_includes_limit("-- LIMIT 5\nSELECT * FROM table") |
| 416 | |
| 417 | # Test invalid SQL |
| 418 | assert not _query_includes_limit("NOT A VALID SQL QUERY") |
| 419 | assert not _query_includes_limit("") |
| 420 | assert not _query_includes_limit("INSERT INTO t VALUES (1, 2, 3)") |
| 421 | |
| 422 | # Multiple queries |
| 423 | assert ( |
| 424 | _query_includes_limit("SELECT * FROM t; SELECT * FROM t2 LIMIT 5") |
| 425 | is True |
| 426 | ) |
| 427 | assert ( |
| 428 | _query_includes_limit("SELECT * FROM t LIMIT 5; SELECT * FROM t2") |
| 429 | is False |
| 430 | ) |
| 431 | |
| 432 | |
| 433 | @patch("marimo._sql.sql.replace") |
nothing calls this directly
no test coverage detected
searching dependent graphs…