diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-10-03 23:00:04 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-10-03 23:00:04 +0000 |
| commit | bbd7c660560212844de3a92ba077bcec77740b16 (patch) | |
| tree | ea4636813813fb80b8f18d24ec931c8fa522b05e /test/sql/query.py | |
| parent | ec6d7b39003f244b4acc7352f5973c910053e17f (diff) | |
| download | sqlalchemy-bbd7c660560212844de3a92ba077bcec77740b16.tar.gz | |
- Function objects know what to do in a FROM clause now. their
behavior should be the same, except now you can also do things like
select(['*'], from_obj=[func.my_function()]) to get multiple
columns from the result, or even use sql.column() constructs to name the
return columns [ticket:172]. generally only postgres understands the
syntax (and possibly oracle).
Diffstat (limited to 'test/sql/query.py')
| -rw-r--r-- | test/sql/query.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/sql/query.py b/test/sql/query.py index 75b1cea5c..2c92a4932 100644 --- a/test/sql/query.py +++ b/test/sql/query.py @@ -188,6 +188,26 @@ class QueryTest(PersistTest): r = db.execute('select user_name from query_users', {}).fetchone() self.assertEqual(len(r), 1) r.close() + + def test_functions(self): + x = testbase.db.func.current_date().execute().scalar() + y = testbase.db.func.current_date().select().execute().scalar() + z = testbase.db.func.current_date().scalar() + assert x == y == z + + @testbase.supported('postgres') + def test_functions_with_cols(self): + x = testbase.db.func.current_date().execute().scalar() + y = testbase.db.func.current_date().select().execute().scalar() + z = testbase.db.func.current_date().scalar() + w = select(['*'], from_obj=[testbase.db.func.current_date()]).scalar() + + # construct a column-based FROM object out of a function, like in [ticket:172] + s = select([column('date', type=DateTime)], from_obj=[testbase.db.func.current_date()]) + q = s.execute().fetchone()[s.c.date] + r = s.alias('datequery').select().scalar() + + assert x == y == z == w == q == r def test_column_order_with_simple_query(self): # should return values in column definition order |
