From: Michael Bayer Date: Mon, 3 Jun 2024 14:25:01 +0000 (+0000) Subject: Merge "Add missing function element methods" into rel_2_0 X-Git-Tag: rel_2_0_31~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa208b7979273a456077fac7c4e360c5af29112d;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Merge "Add missing function element methods" into rel_2_0 --- fa208b7979273a456077fac7c4e360c5af29112d diff --cc test/sql/test_functions.py index c324c8f33a,7782f215bc..b7e82391c1 --- a/test/sql/test_functions.py +++ b/test/sql/test_functions.py @@@ -844,18 -844,19 +844,30 @@@ class CompileTest(fixtures.TestBase, As "AS anon_1 FROM mytable", ) + def test_funcfilter_more_criteria(self): + ff = func.rank().filter(table1.c.name > "foo") + ff2 = ff.filter(table1.c.myid == 1) + self.assert_compile( + select(ff, ff2), + "SELECT rank() FILTER (WHERE mytable.name > :name_1) AS anon_1, " + "rank() FILTER (WHERE mytable.name > :name_1 AND " + "mytable.myid = :myid_1) AS anon_2 FROM mytable", + {"name_1": "foo", "myid_1": 1}, + ) + def test_funcfilter_within_group(self): + self.assert_compile( + select( + func.rank() + .filter(table1.c.name > "foo") + .within_group(table1.c.name) + ), + "SELECT rank() FILTER (WHERE mytable.name > :name_1) " + "WITHIN GROUP (ORDER BY mytable.name) " + "AS anon_1 FROM mytable", + ) + + def test_within_group(self): stmt = select( table1.c.myid, func.percentile_cont(0.5).within_group(table1.c.name),