diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-11-20 17:33:28 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-11-20 17:33:28 -0500 |
commit | fac7bcf97b2f5b74ce1e74c94dacfbc7cd547d1e (patch) | |
tree | 4c6c35a71cf021939266ded9e6beb36f79b55983 | |
parent | 8c5db73b61b911e511aa95685cdb5c94f79307f1 (diff) | |
download | alembic-fac7bcf97b2f5b74ce1e74c94dacfbc7cd547d1e.tar.gz |
- fix some bugs with stamping in --sql mode, log output
-rw-r--r-- | alembic/command.py | 3 | ||||
-rw-r--r-- | alembic/script.py | 2 | ||||
-rw-r--r-- | tests/test_command.py | 9 |
3 files changed, 13 insertions, 1 deletions
diff --git a/alembic/command.py b/alembic/command.py index 4c36c39..8b9f4d7 100644 --- a/alembic/command.py +++ b/alembic/command.py @@ -316,6 +316,9 @@ def stamp(config, revision, sql=False, tag=None): if not sql: raise util.CommandError("Range revision not allowed") starting_rev, revision = revision.split(':', 2) + starting_rev = script.get_revision(starting_rev) + if starting_rev is not None: + starting_rev = starting_rev.revision def do_stamp(rev, context): return script._stamp_revs(revision, rev) diff --git a/alembic/script.py b/alembic/script.py index d47a775..1835605 100644 --- a/alembic/script.py +++ b/alembic/script.py @@ -334,7 +334,7 @@ class ScriptDirectory(object): else: # destination is in a branch not represented, # treat it as new branch - step = migration.StampStep([None], dest.revision, True, True) + step = migration.StampStep((), dest.revision, True, True) return [step] def run_env(self): diff --git a/tests/test_command.py b/tests/test_command.py index 04de5f9..933b347 100644 --- a/tests/test_command.py +++ b/tests/test_command.py @@ -293,6 +293,15 @@ class UpgradeDowngradeStampTest(TestBase): "WHERE alembic_version.version_num = '%s';" % (self.c, self.a) ) in buf.getvalue() + def test_sql_stamp_from_partial_rev(self): + with capture_context_buffer() as buf: + command.stamp(self.cfg, "%s:head" % self.a[0:3], sql=True) + assert ( + "UPDATE alembic_version " + "SET version_num='%s' " + "WHERE alembic_version.version_num = '%s';" % (self.c, self.a) + ) in buf.getvalue() + class LiveStampTest(TestBase): __only_on__ = 'sqlite' |