]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed bug in new :meth:`.DialectKWArgs.argument_for` method where
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 16 Apr 2014 03:34:07 +0000 (23:34 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 16 Apr 2014 03:34:07 +0000 (23:34 -0400)
adding an argument for a construct not previously included for any
special arguments would fail. fixes #3024

doc/build/changelog/changelog_09.rst
lib/sqlalchemy/sql/base.py
test/sql/test_metadata.py

index 05e57cf996b18a87ffb4be5e0bdc84dcec89477e..313e34193958a571d4784340a92e374ab4cfb7a7 100644 (file)
 .. 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
index 379f61ed79f0c26a6b16f49ba782e41a6efeaef3..59f30ed695f1e482e1cf24f5d7373a13775a820b 100644 (file)
@@ -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
index 978f4f1f4e5f0c72d5dd5a8e521309f793c7466b..118fdf15725043eec2626d64fe1e9e83805e4c78 100644 (file)
@@ -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(