diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-09-06 16:37:37 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-09-06 16:37:37 +0000 |
| commit | 986e82700e2ddd82a74c4b5a48fa49d4fa89bdec (patch) | |
| tree | 8a532421629b47e57ca52fa4b6f69bafbbc27342 /test/sql/select.py | |
| parent | 5edafbe9551ca12239f434f7165fea2d4de8d296 (diff) | |
| download | sqlalchemy-986e82700e2ddd82a74c4b5a48fa49d4fa89bdec.tar.gz | |
- column defaults and onupdates, executing inline, will add parenthesis
for subqueries and other parenthesis-requiring expressions
Diffstat (limited to 'test/sql/select.py')
| -rw-r--r-- | test/sql/select.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/sql/select.py b/test/sql/select.py index edca33bc0..f0af7e238 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -1187,7 +1187,33 @@ class CRUDTest(SQLCompileTest): s = select([table2.c.othername], table2.c.otherid == table1.c.myid) u = table1.delete(table1.c.name==s) self.assert_compile(u, "DELETE FROM mytable WHERE mytable.name = (SELECT myothertable.othername FROM myothertable WHERE myothertable.otherid = mytable.myid)") + +class InlineDefaultTest(SQLCompileTest): + def test_insert(self): + m = MetaData() + foo = Table('foo', m, + Column('id', Integer)) + t = Table('test', m, + Column('col1', Integer, default=func.foo(1)), + Column('col2', Integer, default=select([func.coalesce(func.max(foo.c.id))])), + ) + + self.assert_compile(t.insert(inline=True, values={}), "INSERT INTO test (col1, col2) VALUES (foo(:foo), (SELECT coalesce(max(foo.id)) FROM foo))") + + def test_update(self): + m = MetaData() + foo = Table('foo', m, + Column('id', Integer)) + + t = Table('test', m, + Column('col1', Integer, onupdate=func.foo(1)), + Column('col2', Integer, onupdate=select([func.coalesce(func.max(foo.c.id))])), + Column('col3', String(30)) + ) + + self.assert_compile(t.update(inline=True, values={'col3':'foo'}), "UPDATE test SET col1=foo(:foo), col2=(SELECT coalesce(max(foo.id)) FROM foo), col3=:col3") + class SchemaTest(SQLCompileTest): def testselect(self): # these tests will fail with the MS-SQL compiler since it will alias schema-qualified tables |
