]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
- [bug] Fixed MySQL rendering for server_default which
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 23 Aug 2012 01:02:48 +0000 (21:02 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 23 Aug 2012 01:02:48 +0000 (21:02 -0400)
  didn't work if the server_default was a generated
  SQL expression.  Courtesy Moriyoshi Koizumi.

CHANGES
alembic/__init__.py
tests/test_mysql.py

diff --git a/CHANGES b/CHANGES
index 1de83319050533a6ab405a93819eee9e296b3184..d22b4f14146523e956f8a01f2d1ee7e0498dd4b6 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+0.3.7
+=====
+- [bug] Fixed MySQL rendering for server_default which
+  didn't work if the server_default was a generated
+  SQL expression.  Courtesy Moriyoshi Koizumi.
+
 0.3.6
 =====
 - [feature] Added include_symbol option to
index 38e810773a2349994574238187c1171f4d4dc355..36db19fe6a3b404766af0cbee7b101acb8004f62 100644 (file)
@@ -1,6 +1,6 @@
 from os import path
 
-__version__ = '0.3.6'
+__version__ = '0.3.7'
 
 package_dir = path.abspath(path.dirname(__file__))
 
index a47ef9d5ba46559fea70506f0062165be1dc7bbc..02f0419249f95859da9cc59caf24f456d0183e6c 100644 (file)
@@ -1,7 +1,8 @@
 from tests import op_fixture, assert_raises_message
 from alembic import op, util
 from sqlalchemy import Integer, Column, ForeignKey, \
-            UniqueConstraint, Table, MetaData, String
+            UniqueConstraint, Table, MetaData, String,\
+            func
 from sqlalchemy.sql import table
 
 def test_rename_column():
@@ -18,6 +19,16 @@ def test_rename_column_serv_default():
         "ALTER TABLE t1 CHANGE c1 c2 INTEGER NULL DEFAULT 'q'"
     )
 
+def test_rename_column_serv_compiled_default():
+    context = op_fixture('mysql')
+    op.alter_column('t1', 'c1', name="c2", existing_type=Integer,
+            existing_server_default=func.utc_thing(func.current_timestamp()))
+    # this is not a valid MySQL default but the point is to just
+    # test SQL expression rendering
+    context.assert_(
+        "ALTER TABLE t1 CHANGE c1 c2 INTEGER NULL DEFAULT utc_thing(CURRENT_TIMESTAMP)"
+    )
+
 def test_col_nullable():
     context = op_fixture('mysql')
     op.alter_column('t1', 'c1', nullable=False, existing_type=Integer)