]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Merge "Add missing function element methods" into rel_2_0
authorMichael Bayer <mike_mp@zzzcomputing.com>
Mon, 3 Jun 2024 14:25:01 +0000 (14:25 +0000)
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>
Mon, 3 Jun 2024 14:25:01 +0000 (14:25 +0000)
1  2 
lib/sqlalchemy/sql/elements.py
test/sql/test_functions.py

Simple merge
index c324c8f33abebe7d7791e0ea91aca773e1226994,7782f215bcd16df861cdf1c6938fddffbf1eaa74..b7e82391c16fe2c371c82b220bd3aa0a7c364ba6
@@@ -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),