diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-04-26 16:34:14 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-04-26 16:34:14 +0000 |
| commit | f3bcc15c5ca153932a35401a3b37082eb41a9d08 (patch) | |
| tree | 2551465ea2326f0982188640f8776f6c020be9a5 /test/sql/select.py | |
| parent | b089e8615b9cec8b7cb4741b1fad8c30afcfc848 (diff) | |
| download | sqlalchemy-f3bcc15c5ca153932a35401a3b37082eb41a9d08.tar.gz | |
- improved behavior of text() expressions when used as
FROM clauses, such as select().select_from(text("sometext"))
[ticket:1014]
- removed _TextFromClause; _TextClause just adds necessary FromClause descriptors
at the class level
Diffstat (limited to 'test/sql/select.py')
| -rw-r--r-- | test/sql/select.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/sql/select.py b/test/sql/select.py index 1e9683592..08faae096 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -717,6 +717,15 @@ FROM mytable, myothertable WHERE foo.id = foofoo(lala) AND datetime(foo) = Today ), "SELECT t.myid, t.name, t.description, foo.f FROM mytable AS t, (select f from bar where lala=heyhey) foo WHERE foo.f = t.id") + # test Text embedded within select_from(), using binds + generate_series = text("generate_series(:x, :y, :z) as s(a)", bindparams=[bindparam('x'), bindparam('y'), bindparam('z')]) + + s =select([(func.current_date() + literal_column("s.a")).label("dates")]).select_from(generate_series) + self.assert_compile(s, "SELECT CURRENT_DATE + s.a AS dates FROM generate_series(:x, :y, :z) as s(a)", checkparams={'y': None, 'x': None, 'z': None}) + + self.assert_compile(s.params(x=5, y=6, z=7), "SELECT CURRENT_DATE + s.a AS dates FROM generate_series(:x, :y, :z) as s(a)", checkparams={'y': 6, 'x': 5, 'z': 7}) + + def test_literal(self): self.assert_compile(select([literal("foo") + literal("bar")], from_obj=[table1]), "SELECT :param_1 || :param_2 AS anon_1 FROM mytable") @@ -1042,6 +1051,8 @@ UNION SELECT mytable.myid FROM mytable" s = select([table1], or_(table1.c.myid==7, table1.c.myid==8, table1.c.myid==bindparam('myid_1'))) self.assertRaisesMessage(exceptions.CompileError, "conflicts with unique bind parameter of the same name", str, s) + + def test_bind_as_col(self): t = table('foo', column('id')) |
