]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
- Fixed bug in the not-internally-used :meth:`.ScriptDirectory.get_base`
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 27 Dec 2013 15:25:51 +0000 (10:25 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 27 Dec 2013 15:25:51 +0000 (10:25 -0500)
method which would fail if called on an empty versions directory.

alembic/script.py
docs/build/changelog.rst
tests/test_revision_create.py

index cd28d7a147e3e43a3a66938363fa0eb570ff3b69..34fd1500c48944eddebcc9ebe83a1d72740b5243 100644 (file)
@@ -297,7 +297,7 @@ class ScriptDirectory(object):
 
         """
         for script in self._revision_map.values():
-            if script.down_revision is None \
+            if script and script.down_revision is None \
                 and script.revision in self._revision_map:
                 return script.revision
         else:
index a8488413308bd71c3ca8eac2682259dc1d69d620..088018ef11ef965f82657fd73fa293d698dd5cda 100644 (file)
@@ -6,6 +6,12 @@ Changelog
 .. changelog::
     :version: 0.6.2
 
+    .. change::
+      :tags: bug
+
+      Fixed bug in the not-internally-used :meth:`.ScriptDirectory.get_base`
+      method which would fail if called on an empty versions directory.
+
     .. change::
       :tags: bug
       :tickets: 157
index aa85809bb5e24e3135d9fe87350442789fc3df2e..07ed6d44639e24129c3afa94020ce925efc7a335 100644 (file)
@@ -24,9 +24,11 @@ class GeneralOrderedTests(unittest.TestCase):
         def_ = util.rev_id()
         ne_(abc, def_)
 
-    def test_003_heads(self):
+    def test_003_api_methods_clean(self):
         eq_(env.get_heads(), [])
 
+        eq_(env.get_base(), None)
+
     def test_004_rev(self):
         script = env.generate_revision(abc, "this is a message", refresh=True)
         eq_(script.doc, "this is a message")
@@ -36,6 +38,7 @@ class GeneralOrderedTests(unittest.TestCase):
             os.path.join(env.dir, 'versions', '%s_this_is_a_message.py' % abc), os.F_OK)
         assert callable(script.module.upgrade)
         eq_(env.get_heads(), [abc])
+        eq_(env.get_base(), abc)
 
     def test_005_nextrev(self):
         script = env.generate_revision(def_, "this is the next rev", refresh=True)
@@ -48,6 +51,7 @@ class GeneralOrderedTests(unittest.TestCase):
         assert callable(script.module.upgrade)
         assert callable(script.module.downgrade)
         eq_(env.get_heads(), [def_])
+        eq_(env.get_base(), abc)
 
     def test_006_from_clean_env(self):
         # test the environment so far with a
@@ -60,6 +64,7 @@ class GeneralOrderedTests(unittest.TestCase):
         eq_(abc_rev.revision, abc)
         eq_(def_rev.down_revision, abc)
         eq_(env.get_heads(), [def_])
+        eq_(env.get_base(), abc)
 
     def test_007_no_refresh(self):
         rid = util.rev_id()