diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-07-19 17:56:18 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-07-19 17:56:18 -0400 |
commit | c7312cc508eadc9e85a3de0dc56c9906dccdf7a1 (patch) | |
tree | fc0667f929ec99797e6cd8340c5e9a726a84812d | |
parent | 1c65ddee24f77b9751f05ba50b618234a6a039c5 (diff) | |
download | sqlalchemy-c7312cc508eadc9e85a3de0dc56c9906dccdf7a1.tar.gz |
- changelog for #3459, fixes #3459
- test for .cast() method has no good place now except for
test_cast in test_compiler.py
-rw-r--r-- | doc/build/changelog/changelog_10.rst | 9 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/elements.py | 5 | ||||
-rw-r--r-- | test/sql/test_compiler.py | 2 | ||||
-rw-r--r-- | test/sql/test_type_expressions.py | 7 |
4 files changed, 15 insertions, 8 deletions
diff --git a/doc/build/changelog/changelog_10.rst b/doc/build/changelog/changelog_10.rst index a2b4273bf..1be278a9a 100644 --- a/doc/build/changelog/changelog_10.rst +++ b/doc/build/changelog/changelog_10.rst @@ -19,6 +19,15 @@ :version: 1.0.7 .. change:: + :tags: feature, sql + :tickets: 3459 + :pullreq: bitbucket:56 + + Added a :meth:`.ColumnElement.cast` method which performs the same + purpose as the standalone :func:`.cast` function. Pull request + courtesy Sebastian Bank. + + .. change:: :tags: bug, engine :tickets: 3481 diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index 4af1e4463..a44c308eb 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -847,7 +847,10 @@ class ColumnElement(operators.ColumnOperators, ClauseElement): def cast(self, type_): """Produce a type cast, i.e. ``CAST(<expression> AS <type>)``. - This is a shortcut to the :func:`.cast` function. + This is a shortcut to the :func:`~.expression.cast` function. + + .. versionadded:: 1.0.7 + """ return Cast(self, type_) diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index 04e3171a9..06cb80ba0 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -2040,6 +2040,8 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): 'Incorrect number of expected results') eq_(str(cast(tbl.c.v1, Numeric).compile(dialect=dialect)), 'CAST(casttest.v1 AS %s)' % expected_results[0]) + eq_(str(tbl.c.v1.cast(Numeric).compile(dialect=dialect)), + 'CAST(casttest.v1 AS %s)' % expected_results[0]) eq_(str(cast(tbl.c.v1, Numeric(12, 9)).compile(dialect=dialect)), 'CAST(casttest.v1 AS %s)' % expected_results[1]) eq_(str(cast(tbl.c.ts, Date).compile(dialect=dialect)), diff --git a/test/sql/test_type_expressions.py b/test/sql/test_type_expressions.py index c35e9ff53..574edfe9e 100644 --- a/test/sql/test_type_expressions.py +++ b/test/sql/test_type_expressions.py @@ -40,13 +40,6 @@ class SelectTest(_ExprFixture, fixtures.TestBase, AssertsCompiledSQL): "SELECT CAST(test_table.y AS VARCHAR) AS anon_1 FROM test_table" ) - def test_cast_method(self): - table = self._fixture() - self.assert_compile( - select([table.c.y.cast(String)]), - "SELECT CAST(test_table.y AS VARCHAR) AS anon_1 FROM test_table" - ) - def test_select_cols_use_labels(self): table = self._fixture() |