From b6a0ba0164b2d2d786ec2e3b5e06349018897f0f Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 15 Sep 2017 20:25:43 -0400 Subject: [PATCH] Add + to illegal revision characters list An addition to :ticket:`441` fixed in 0.9.5, we forgot to also filter for the ``+`` sign in migration names which also breaks due to the relative migrations feature. Change-Id: I94d3882e84ba13e7569b47230dc9422a8ac6408c Fixes: #445 --- alembic/script/revision.py | 2 +- docs/build/unreleased/441.rst | 7 +++++++ tests/test_script_production.py | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 docs/build/unreleased/441.rst diff --git a/alembic/script/revision.py b/alembic/script/revision.py index 7e25a865..1e68a7c3 100644 --- a/alembic/script/revision.py +++ b/alembic/script/revision.py @@ -6,7 +6,7 @@ from sqlalchemy import util as sqlautil from ..util import compat _relative_destination = re.compile(r'(?:(.+?)@)?(\w+)?((?:\+|-)\d+)') -_revision_illegal_chars = ['@', '-'] +_revision_illegal_chars = ['@', '-', '+'] class RevisionError(Exception): diff --git a/docs/build/unreleased/441.rst b/docs/build/unreleased/441.rst new file mode 100644 index 00000000..9bacef81 --- /dev/null +++ b/docs/build/unreleased/441.rst @@ -0,0 +1,7 @@ +.. change:: + :tags: bug, commands + :tickets: 441 + + An addition to :ticket:`441` fixed in 0.9.5, we forgot to also filter + for the ``+`` sign in migration names which also breaks due to the relative + migrations feature. \ No newline at end of file diff --git a/tests/test_script_production.py b/tests/test_script_production.py index dca06ac9..588b9d1f 100644 --- a/tests/test_script_production.py +++ b/tests/test_script_production.py @@ -292,6 +292,14 @@ class RevisionCommandTest(TestBase): self.cfg, message="some message", rev_id="no@atsigns-ordashes" ) + assert_raises_message( + util.CommandError, + r"Character\(s\) '\+' not allowed in revision " + r"identifier 'no\+plussignseither'", + command.revision, + self.cfg, message="some message", rev_id="no+plussignseither" + ) + def test_create_script_branches(self): rev = command.revision( self.cfg, message="some message", branch_label="foobar") -- 2.47.2