]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Add colon (:) to invalid char for revision name add unittest
authorKim Wooseok <eypk9673@gendata.kr>
Tue, 28 Oct 2025 12:05:24 +0000 (08:05 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 28 Oct 2025 12:58:37 +0000 (08:58 -0400)
Disallow ':' character in custom revision identifiers. Previously, using a
colon in a revision ID (e.g., 'REV:1') would create the revision, however
revisions with colons in them are not correctly interpreted by other
commands, as it overlaps with the revision range syntax.   Pull request
courtesy Kim Wooseok with original implementation by Hrushikesh Patil.

Fixes: #1540
Closes: #1741
Pull-request: https://github.com/sqlalchemy/alembic/pull/1741
Pull-request-sha: 3894b1f9a1b1685a01465f53886af9086e23d079

Change-Id: Ie935f0e04981a0b3d0ac8a2ac03ffebce898280a

alembic/script/revision.py
docs/build/unreleased/1540.rst [new file with mode: 0644]
tests/test_script_production.py

index 587e90497ce0e4313452441b3611957453eb6349..5825da34f48dbd92a91e32cf5aa66ea01bbd8fc8 100644 (file)
@@ -45,7 +45,7 @@ _T = TypeVar("_T")
 _TR = TypeVar("_TR", bound=Optional[_RevisionOrStr])
 
 _relative_destination = re.compile(r"(?:(.+?)@)?(\w+)?((?:\+|-)\d+)")
-_revision_illegal_chars = ["@", "-", "+"]
+_revision_illegal_chars = ["@", "-", "+", ":"]
 
 
 class _CollectRevisionsProtocol(Protocol):
diff --git a/docs/build/unreleased/1540.rst b/docs/build/unreleased/1540.rst
new file mode 100644 (file)
index 0000000..c0f8f0d
--- /dev/null
@@ -0,0 +1,9 @@
+.. change::
+    :tags: bug, commands
+    :tickets: 1540
+
+    Disallow ':' character in custom revision identifiers. Previously, using a
+    colon in a revision ID (e.g., 'REV:1') would create the revision, however
+    revisions with colons in them are not correctly interpreted by other
+    commands, as it overlaps with the revision range syntax.   Pull request
+    courtesy Kim Wooseok with original implementation by Hrushikesh Patil.
\ No newline at end of file
index 0015046891af3406a21c09be039fef1c118e8b16..853767dc805f812eec117705aaac7d4d4a8d6e3e 100644 (file)
@@ -393,6 +393,16 @@ class RevisionCommandTest(TestBase):
             rev_id="no@atsigns",
         )
 
+        assert_raises_message(
+            util.CommandError,
+            r"Character\(s\) ':' not allowed in "
+            "revision identifier 'no:colons'",
+            command.revision,
+            self.cfg,
+            message="some message",
+            rev_id="no:colons",
+        )
+
         assert_raises_message(
             util.CommandError,
             r"Character\(s\) '-, @' not allowed in revision "