diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-07 00:56:05 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-07 00:56:05 +0000 |
commit | 1c73149d5dd477ae882890e155e87f5dd9e4853f (patch) | |
tree | 1433f2fa80a06b2619f6aea5f12f0018572861a6 /test/sql/test_functions.py | |
parent | 54df3ee2ab1052533f49e596d902d597eb140c52 (diff) | |
download | sqlalchemy-1c73149d5dd477ae882890e155e87f5dd9e4853f.tar.gz |
- FunctionElement subclasses are now directly executable the
same way any func.foo() construct is, with automatic
SELECT being applied when passed to execute().
- The "type" and "bind" keyword arguments of a func.foo()
construct are now local to "func." constructs and are
not part of the FunctionElement base class, allowing
a "type" to be handled in a custom constructor or
class-level variable.
Diffstat (limited to 'test/sql/test_functions.py')
-rw-r--r-- | test/sql/test_functions.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/test/sql/test_functions.py b/test/sql/test_functions.py index 7a0f12cac..e6bcd2680 100644 --- a/test/sql/test_functions.py +++ b/test/sql/test_functions.py @@ -196,15 +196,26 @@ class ExecuteTest(TestBase): assert isinstance(x.execute().scalar(), datetime.date) def test_conn_execute(self): + from sqlalchemy.sql.expression import FunctionElement + from sqlalchemy.ext.compiler import compiles + + class myfunc(FunctionElement): + type = DATE() + + @compiles(myfunc) + def compile(elem, compiler, **kw): + return compiler.process(func.current_date()) + conn = testing.db.connect() try: x = conn.execute(func.current_date()).scalar() y = conn.execute(func.current_date().select()).scalar() z = conn.scalar(func.current_date()) + q = conn.scalar(myfunc()) finally: conn.close() - assert (x == y == z) is True - + assert (x == y == z == q) is True + @engines.close_first def test_update(self): """ |