diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-12-18 00:24:03 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-12-18 00:24:03 +0000 |
| commit | f6068a3522bb92fac18c930eb26798fc4cb1889f (patch) | |
| tree | 2ce96db7758621f605ea605342a106309e134d56 /test/sql/select.py | |
| parent | 420c098d56e9925b51067711c6817475165c6af2 (diff) | |
| download | sqlalchemy-f6068a3522bb92fac18c930eb26798fc4cb1889f.tar.gz | |
- select().as_scalar() will raise an exception if the select does not have
exactly one expression in its columns clause.
- added "helper exception" to select.type access, generic functions raise
the chance of this happening
- a slight behavioral change to attributes is, del'ing an attribute
does *not* cause the lazyloader of that attribute to fire off again;
the "del" makes the effective value of the attribute "None". To
re-trigger the "loader" for an attribute, use
session.expire(instance, [attrname]).
- fix ormtutorial for IS NULL
Diffstat (limited to 'test/sql/select.py')
| -rw-r--r-- | test/sql/select.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/test/sql/select.py b/test/sql/select.py index 10e92a083..3f613596e 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -60,7 +60,7 @@ class SelectTest(SQLCompileTest): assert hasattr(table1.select(), 'c') assert not hasattr(table1.c.myid.self_group(), 'columns') assert hasattr(table1.select().self_group(), 'columns') - assert not hasattr(table1.select().as_scalar().self_group(), 'columns') + assert not hasattr(select([table1.c.myid]).as_scalar().self_group(), 'columns') assert not hasattr(table1.c.myid, 'columns') assert not hasattr(table1.c.myid, 'c') assert not hasattr(table1.select().c.myid, 'c') @@ -245,6 +245,19 @@ sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") A def test_scalar_select(self): + try: + s = select([table1.c.myid, table1.c.name]).as_scalar() + assert False + except exceptions.InvalidRequestError, err: + assert str(err) == "Scalar select can only be created from a Select object that has exactly one column expression.", str(err) + + try: + # generic function which will look at the type of expression + func.coalesce(select([table1.c.myid])) + assert False + except exceptions.InvalidRequestError, err: + assert str(err) == "Select objects don't have a type. Call as_scalar() on this Select object to return a 'scalar' version of this Select.", str(err) + s = select([table1.c.myid], scalar=True, correlate=False) self.assert_compile(select([table1, s]), "SELECT mytable.myid, mytable.name, mytable.description, (SELECT mytable.myid FROM mytable) AS anon_1 FROM mytable") |
