--- /dev/null
+.. change::
+ :tags: usecase, mysql, mariadb
+ :tickets: 8503
+
+ The ``ROLLUP`` function will now correctly render ``WITH ROLLUP`` on
+ MySql and MariaDB, allowing the use of group by rollup with these
+ backend.
def visit_random_func(self, fn, **kw):
return "rand%s" % self.function_argspec(fn)
+ def visit_rollup_func(self, fn, **kw):
+ clause = ", ".join(
+ elem._compiler_dispatch(self, **kw) for elem in fn.clauses
+ )
+ return f"{clause} WITH ROLLUP"
+
def visit_sequence(self, seq, **kw):
return "nextval(%s)" % self.preparer.format_sequence(seq)
"ALWAYS AS (x + 2)%s)" % text,
)
+ def test_groupby_rollup(self):
+ t = table("tt", column("foo"), column("bar"))
+ q = sql.select(t.c.foo).group_by(sql.func.rollup(t.c.foo, t.c.bar))
+ self.assert_compile(
+ q, "SELECT tt.foo FROM tt GROUP BY tt.foo, tt.bar WITH ROLLUP"
+ )
+
class SQLTest(fixtures.TestBase, AssertsCompiledSQL):