Fixed issue where ``get_x_arguments(as_dictionary=True)`` would fail if an
argument key were passed without an equal sign ``=`` or a value.
Behavior is repaired where this condition is detected and will return a
blank string for the given key, consistent with the behavior where the
``=`` sign is present and no value. Pull request courtesy Iuri de Silvio.
Fixes: #1369
Closes: #1370
Pull-request: https://github.com/sqlalchemy/alembic/pull/1370
Pull-request-sha:
830a69076653d0849f0b3eba2ecbf6ff16700049
Change-Id: I610d2d9022a0a08e56e0f62f6890f3f0d5bc169a
The return value is a list, returned directly from the ``argparse``
structure. If ``as_dictionary=True`` is passed, the ``x`` arguments
are parsed using ``key=value`` format into a dictionary that is
- then returned.
+ then returned. If there is no ``=`` in the argument, value is an empty
+ string.
+
+ .. versionchanged:: 1.13.1 Support ``as_dictionary=True`` when
+ arguments are passed without the ``=`` symbol.
For example, to support passing a database URL on the command line,
the standard ``env.py`` script can be modified like this::
The return value is a list, returned directly from the ``argparse``
structure. If ``as_dictionary=True`` is passed, the ``x`` arguments
are parsed using ``key=value`` format into a dictionary that is
- then returned.
+ then returned. If there is no ``=`` in the argument, value is an empty
+ string.
+
+ .. versionchanged:: 1.13.1 Support ``as_dictionary=True`` when
+ arguments are passed without the ``=`` symbol.
For example, to support passing a database URL on the command line,
the standard ``env.py`` script can be modified like this::
else:
value = []
if as_dictionary:
- value = dict(arg.split("=", 1) for arg in value)
+ dict_value = {}
+ for arg in value:
+ x_key, _, x_value = arg.partition("=")
+ dict_value[x_key] = x_value
+ value = dict_value
+
return value
def configure(
--- /dev/null
+.. change::
+ :tags: bug, environment
+ :tickets: 1369
+
+ Fixed issue where ``get_x_arguments(as_dictionary=True)`` would fail if an
+ argument key were passed without an equal sign ``=`` or a value.
+ Behavior is repaired where this condition is detected and will return a
+ blank string for the given key, consistent with the behavior where the
+ ``=`` sign is present and no value. Pull request courtesy Iuri de Silvio.
env = self._fixture()
eq_(env.get_x_argument(as_dictionary=True), {})
+ def test_x_arg_empty_value(self):
+ env = self._fixture()
+ self.cfg.cmd_opts = mock.Mock(x=["y"])
+ eq_(env.get_x_argument(as_dictionary=True), {"y": ""})
+
def test_tag_arg(self):
env = self._fixture(tag="x")
eq_(env.get_tag_argument(), "x")