@@ -44,9 +44,18 @@ def low_count():
4444 return low_count_cursor
4545
4646
47- def test_row_limit_with_LIMIT_clause (LIMIT , over_limit ):
47+ @pytest .mark .parametrize (
48+ "stmt" ,
49+ [
50+ "SELECT * FROM students LIMIT 1000" ,
51+ "SELECT * FROM students LIMIT\n 1000" ,
52+ "SELECT * FROM students LIMIT\t 1000" ,
53+ "SELECT * FROM students limit 1000" ,
54+ "SELECT * FROM students LiMiT 1000" ,
55+ ],
56+ )
57+ def test_row_limit_with_LIMIT_clause (LIMIT , over_limit , stmt ):
4858 cli = PGCli (row_limit = LIMIT )
49- stmt = "SELECT * FROM students LIMIT 1000"
5059
5160 result = cli ._should_limit_output (stmt , over_limit )
5261 assert result is False
@@ -56,6 +65,21 @@ def test_row_limit_with_LIMIT_clause(LIMIT, over_limit):
5665 assert result is False
5766
5867
68+ @pytest .mark .parametrize (
69+ "stmt" ,
70+ [
71+ "SELECT 'LIMIT 1000' FROM students" ,
72+ "SELECT * FROM students -- LIMIT 1000" ,
73+ "SELECT * FROM students /* LIMIT 1000 */" ,
74+ ],
75+ )
76+ def test_row_limit_ignores_LIMIT_in_comments_or_strings (LIMIT , over_limit , stmt ):
77+ cli = PGCli (row_limit = LIMIT )
78+
79+ result = cli ._should_limit_output (stmt , over_limit )
80+ assert result is True
81+
82+
5983def test_row_limit_without_LIMIT_clause (LIMIT , over_limit ):
6084 cli = PGCli (row_limit = LIMIT )
6185 stmt = "SELECT * FROM students"
0 commit comments