]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
cut off the slug length at 20 chars
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 30 Jan 2012 18:03:43 +0000 (13:03 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 30 Jan 2012 18:03:43 +0000 (13:03 -0500)
alembic/script.py
tests/test_revision_create.py

index 5598b78fd4445045203be18ed13e56b46a3975f6..bc5b66af5d2af763ab0fc44f97716a6d0ea887a5 100644 (file)
@@ -149,7 +149,7 @@ class ScriptDirectory(object):
         return map_
 
     def _rev_path(self, rev_id, message):
-        slug = "_".join(_slug_re.findall(message or "")[0:20]).lower()
+        slug = "_".join(_slug_re.findall(message or "")).lower()[0:20]
         filename = "%s.py" % (
             self.file_template % {'rev':rev_id, 'slug':slug}
         )
index 51aade272a57753fb1619c2e33e8dd03a215e472..2bdca938ab4fe26afae19097279ad91fd1b5be98 100644 (file)
@@ -58,6 +58,15 @@ def test_007_no_refresh():
     env2 = staging_env(create=False)
     eq_(script, env2._as_rev_number("head"))
 
+def test_008_long_name():
+    rid = util.rev_id()
+    script = env.generate_rev(rid, 
+            "this is a really long name with "
+            "lots of characters and also "
+            "I'd like it to\nhave\nnewlines")
+    assert os.access(
+        os.path.join(env.dir, 'versions', '%s_this_is_a_really_lon.py' % rid), os.F_OK)
+
 
 def setup():
     global env