diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-10-24 15:37:06 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-10-24 15:37:06 -0400 |
| commit | 07d7c4905d65b7f28c1ffcbd33f81ee52c9fd847 (patch) | |
| tree | a9c1213e4db2f905d65ae5cef2eed101560fe9be /test/sql/test_compiler.py | |
| parent | e656bf4f47cf3c06975c6207ea6e54131b292bf7 (diff) | |
| download | sqlalchemy-07d7c4905d65b7f28c1ffcbd33f81ee52c9fd847.tar.gz | |
Fixed bug where keyword arguments passed to
:meth:`.Compiler.process` wouldn't get propagated
to the column expressions present in the columns
clause of a SELECT statement. In particular this would
come up when used by custom compilation schemes that
relied upon special flags. [ticket:2593]
Diffstat (limited to 'test/sql/test_compiler.py')
| -rw-r--r-- | test/sql/test_compiler.py | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index bb819472a..50b425a01 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -18,7 +18,7 @@ from sqlalchemy import Integer, String, MetaData, Table, Column, select, \ insert, literal, and_, null, type_coerce, alias, or_, literal_column,\ Float, TIMESTAMP, Numeric, Date, Text, collate, union, except_,\ intersect, union_all, Boolean, distinct, join, outerjoin, asc, desc,\ - over, subquery + over, subquery, case import decimal from sqlalchemy import exc, sql, util, types, schema from sqlalchemy.sql import table, column, label @@ -2437,6 +2437,53 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): ) +class KwargPropagationTest(fixtures.TestBase): + + @classmethod + def setup_class(cls): + from sqlalchemy.sql.expression import ColumnClause, TableClause + class CatchCol(ColumnClause): + pass + + class CatchTable(TableClause): + pass + + cls.column = CatchCol("x") + cls.table = CatchTable("y") + cls.criterion = cls.column == CatchCol('y') + + @compiles(CatchCol) + def compile_col(element, compiler, **kw): + assert "canary" in kw + return compiler.visit_column(element) + + @compiles(CatchTable) + def compile_table(element, compiler, **kw): + assert "canary" in kw + return compiler.visit_table(element) + + def _do_test(self, element): + d = default.DefaultDialect() + d.statement_compiler(d, element, + compile_kwargs={"canary": True}) + + def test_binary(self): + self._do_test(self.column == 5) + + def test_select(self): + s = select([self.column]).select_from(self.table).\ + where(self.column == self.criterion).\ + order_by(self.column) + self._do_test(s) + + def test_case(self): + c = case([(self.criterion, self.column)], else_=self.column) + self._do_test(c) + + def test_cast(self): + c = cast(self.column, Integer) + self._do_test(c) + class CRUDTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' |
