]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- changelog for #3459, fixes #3459
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 19 Jul 2015 21:56:18 +0000 (17:56 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 19 Jul 2015 21:56:18 +0000 (17:56 -0400)
- test for .cast() method has no good place now except for
test_cast in test_compiler.py

doc/build/changelog/changelog_10.rst
lib/sqlalchemy/sql/elements.py
test/sql/test_compiler.py
test/sql/test_type_expressions.py

index a2b4273bf684a395f3f2f00f99643951fd3a966f..1be278a9afbd69b5d42edd4ccee5f2e63836be81 100644 (file)
 .. changelog::
     :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
index 4af1e44634cc90b11ede970d7cf5b2a82571cbe4..a44c308eb72d25858585cd4030f370da7402d722 100644 (file)
@@ -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_)
 
index 04e3171a9f23d7282381bb234815b49e42baa55a..06cb80ba0f46ef627e17fea6ef5dab14655c4b8e 100644 (file)
@@ -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)),
index c35e9ff538d549359beb0dcf5a52cd458eef0d4f..574edfe9e849dd407b00b2daa03368719e3794ae 100644 (file)
@@ -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()