summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-04-15 23:34:07 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-04-15 23:34:07 -0400
commit99ae0dc821a1a36a6d1a966f51843f6632fc4117 (patch)
tree7b9f1f348af97340bf008e2e76b7a0898589672d
parent0c4a1cf963ab5fab876ef2bc56d06b01b83d5c63 (diff)
downloadsqlalchemy-99ae0dc821a1a36a6d1a966f51843f6632fc4117.tar.gz
- 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
-rw-r--r--doc/build/changelog/changelog_09.rst8
-rw-r--r--lib/sqlalchemy/sql/base.py2
-rw-r--r--test/sql/test_metadata.py11
3 files changed, 21 insertions, 0 deletions
diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst
index 05e57cf99..313e34193 100644
--- a/doc/build/changelog/changelog_09.rst
+++ b/doc/build/changelog/changelog_09.rst
@@ -15,6 +15,14 @@
: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
:pullreq: bitbucket:2830
diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py
index 379f61ed7..59f30ed69 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 978f4f1f4..118fdf157 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(