diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-10-28 18:25:37 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-10-28 18:25:37 +0000 |
| commit | 19fcf37483b381d795239fa328d08ce97b87ed90 (patch) | |
| tree | 22e5b75c43bd46c2441e7a2625fee937424143e1 /test/sql/generative.py | |
| parent | 103c867cf38a36db076eb1a841548638cbca0336 (diff) | |
| download | sqlalchemy-19fcf37483b381d795239fa328d08ce97b87ed90.tar.gz | |
- fixed expression translation of text() clauses; this repairs various
ORM scenarios where literal text is used for SQL expressions
Diffstat (limited to 'test/sql/generative.py')
| -rw-r--r-- | test/sql/generative.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/test/sql/generative.py b/test/sql/generative.py index bcf5d6a5f..437f0874e 100644 --- a/test/sql/generative.py +++ b/test/sql/generative.py @@ -3,6 +3,7 @@ from sqlalchemy import * from sqlalchemy.sql import table, column, ClauseElement from testlib import * from sqlalchemy.sql.visitors import * +from sqlalchemy import util class TraversalTest(AssertMixin): """test ClauseVisitor's traversal, particularly its ability to copy and modify @@ -165,7 +166,21 @@ class ClauseTest(SQLCompileTest): clause2 = Vis().traverse(clause, clone=True) assert c1 == str(clause) assert str(clause2) == str(t1.join(t2, t1.c.col2==t2.c.col3)) - + + def test_text(self): + clause = text("select * from table where foo=:bar", bindparams=[bindparam('bar')]) + c1 = str(clause) + class Vis(ClauseVisitor): + def visit_textclause(self, text): + text.text = text.text + " SOME MODIFIER=:lala" + text.bindparams['lala'] = bindparam('lala') + + clause2 = Vis().traverse(clause, clone=True) + assert c1 == str(clause) + assert str(clause2) == c1 + " SOME MODIFIER=:lala" + assert clause.bindparams.keys() == ['bar'] + assert util.Set(clause2.bindparams.keys()) == util.Set(['bar', 'lala']) + def test_select(self): s2 = select([t1]) s2_assert = str(s2) |
