]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
- [bug] Fix autogenerate so that "pass" is
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 20 Dec 2011 21:10:01 +0000 (16:10 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 20 Dec 2011 21:10:01 +0000 (16:10 -0500)
  generated between the two comments
  if no net migrations were present.

CHANGES
alembic/autogenerate.py
tests/test_autogenerate.py

diff --git a/CHANGES b/CHANGES
index ff9f4dfefa118c2ee1df155feab8c8efcd72f24e..68789a2cbd1eb88b42c78e6e5d84fe1feba47dab 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,13 +1,17 @@
 0.1.1
 =====
-- Clean up file write operations so that
+- [bug] Clean up file write operations so that
   file handles are closed.
 
-- PyPy is supported.
+- [feature] PyPy is supported.
 
-- Python 2.5 is supported, needs 
+- [feature] Python 2.5 is supported, needs 
   __future__.with_statement
 
+- [bug] Fix autogenerate so that "pass" is 
+  generated between the two comments
+  if no net migrations were present.
+
 0.1.0
 =====
 - Initial release.  Status of features:
index 31eafee894f308bf42f059f371d4dff4b3020a55..3ddf773c11e89ac083caa2ef868ea39a06c83fe0 100644 (file)
@@ -222,12 +222,16 @@ def _produce_upgrade_commands(diffs, autogen_context):
     buf = []
     for diff in diffs:
         buf.append(_invoke_command("upgrade", diff, autogen_context))
+    if not buf:
+        buf = ["pass"]
     return "\n".join(buf)
 
 def _produce_downgrade_commands(diffs, autogen_context):
     buf = []
     for diff in diffs:
         buf.append(_invoke_command("downgrade", diff, autogen_context))
+    if not buf:
+        buf = ["pass"]
     return "\n".join(buf)
 
 def _invoke_command(updown, args, autogen_context):
index 721f86fdef75a311f35198b04f29b591cac635db..6b0308ff8d5d00ffdb31d28b58e8e6f74201fe1e 100644 (file)
@@ -137,7 +137,23 @@ class AutogenerateDiffTest(TestCase):
         eq_(diffs[7][0][5], False)
 
 
-
+    def test_render_nothing(self):
+        context.configure(
+            connection = self.bind.connect(),
+            compare_type = True,
+            compare_server_default = True,
+            target_metadata=self.m1
+        )
+        template_args = {}
+        autogenerate.produce_migration_diffs(template_args, self.autogen_context)
+        eq_(re.sub(r"u'", "'", template_args['upgrades']),
+"""### commands auto generated by Alembic - please adjust! ###
+    pass
+    ### end Alembic commands ###""")
+        eq_(re.sub(r"u'", "'", template_args['downgrades']),
+"""### commands auto generated by Alembic - please adjust! ###
+    pass
+    ### end Alembic commands ###""")
 
     def test_render_diffs(self):
         """test a full render including indentation"""