From ce3abfa79095605d402d2819d6580badf5318855 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 17 Nov 2014 17:51:59 -0500 Subject: [PATCH] - restore the starting arg error back to the original intent --- alembic/environment.py | 6 +++++- tests/test_offline_environment.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/alembic/environment.py b/alembic/environment.py index a41c81d..279564c 100644 --- a/alembic/environment.py +++ b/alembic/environment.py @@ -179,10 +179,14 @@ class EnvironmentContext(object): if self._migration_context is not None: return self.script.as_revision_number( self.get_context()._start_from_rev) - elif self.context_opts.get('starting_rev') is not None: + elif 'starting_rev' in self.context_opts: return self.script.as_revision_number( self.context_opts['starting_rev']) else: + # this should raise only in the case that a command + # is being run where the "starting rev" is never applicable; + # this is to catch scripts which rely upon this in + # non-sql mode or similar raise util.CommandError( "No starting revision argument is available.") diff --git a/tests/test_offline_environment.py b/tests/test_offline_environment.py index b870dc4..f2695c2 100644 --- a/tests/test_offline_environment.py +++ b/tests/test_offline_environment.py @@ -53,14 +53,14 @@ assert context.get_starting_revision_argument() == 'x' command.upgrade(self.cfg, "x:y", sql=True) command.downgrade(self.cfg, "x:y", sql=True) - def test_starting_rev_pre_context_stamp(self): + def test_starting_rev_pre_context_cmd_w_no_startrev(self): env_file_fixture(""" assert context.get_starting_revision_argument() == 'x' """) assert_raises_message( util.CommandError, "No starting revision argument is available.", - command.stamp, self.cfg, a) + command.current, self.cfg) def test_starting_rev_current_pre_context(self): env_file_fixture("""