From: Mike Bayer Date: Wed, 16 Apr 2014 03:34:07 +0000 (-0400) Subject: - Fixed bug in new :meth:`.DialectKWArgs.argument_for` method where X-Git-Tag: rel_0_9_5~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99ae0dc821a1a36a6d1a966f51843f6632fc4117;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Fixed bug in new :meth:`.DialectKWArgs.argument_for` method where adding an argument for a construct not previously included for any special arguments would fail. fixes #3024 --- diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index 05e57cf996..313e341939 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -14,6 +14,14 @@ .. changelog:: :version: 0.9.5 + .. change:: + :tags: bug, sql + :tickets: 3024 + + Fixed bug in new :meth:`.DialectKWArgs.argument_for` method where + adding an argument for a construct not previously included for any + special arguments would fail. + .. change:: :tags: bug, py3k, tests :tickets: 2830 diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index 379f61ed79..59f30ed695 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -181,6 +181,8 @@ class DialectKWArgs(object): raise exc.ArgumentError("Dialect '%s' does have keyword-argument " "validation and defaults enabled configured" % dialect_name) + if cls not in construct_arg_dictionary: + construct_arg_dictionary[cls] = {} construct_arg_dictionary[cls][argument_name] = default @util.memoized_property diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py index 978f4f1f4e..118fdf1572 100644 --- a/test/sql/test_metadata.py +++ b/test/sql/test_metadata.py @@ -2626,6 +2626,17 @@ class DialectKWArgTest(fixtures.TestBase): idx = Index('a', 'b', 'c') eq_(idx.dialect_options['participating']['xyzqpr'], False) + def test_add_new_arguments_participating_no_existing(self): + with self._fixture(): + PrimaryKeyConstraint.argument_for("participating", "xyzqpr", False) + + pk = PrimaryKeyConstraint('a', 'b', 'c', participating_xyzqpr=True) + + eq_(pk.kwargs['participating_xyzqpr'], True) + + pk = PrimaryKeyConstraint('a', 'b', 'c') + eq_(pk.dialect_options['participating']['xyzqpr'], False) + def test_add_new_arguments_nonparticipating(self): with self._fixture(): assert_raises_message(