This commit is contained in:
Mike Bayer
2014-02-25 20:10:52 -05:00
parent 33f07202ce
commit f9492ef906
4 changed files with 44 additions and 18 deletions
+4 -3
View File
@@ -23,13 +23,14 @@ _convert_modname = {
_convert_modname_w_class = {
("sqlalchemy.engine.interfaces", "Connectable"): "sqlalchemy.engine",
("sqlalchemy.sql.base", "DialectKWArgs"): "sqlalchemy.sql.base",
}
def _adjust_rendered_mod_name(modname, objname):
if modname in _convert_modname:
return _convert_modname[modname]
elif (modname, objname) in _convert_modname_w_class:
if (modname, objname) in _convert_modname_w_class:
return _convert_modname_w_class[(modname, objname)]
elif modname in _convert_modname:
return _convert_modname[modname]
else:
return modname
+11 -3
View File
@@ -431,26 +431,33 @@ name as follows::
Constraints API
---------------
.. autoclass:: Constraint
:members:
.. autoclass:: CheckConstraint
:members:
:inherited-members:
.. autoclass:: ColumnCollectionConstraint
:members:
.. autoclass:: ForeignKey
:members:
:inherited-members:
.. autoclass:: ForeignKeyConstraint
:members:
:inherited-members:
.. autoclass:: PrimaryKeyConstraint
:members:
:inherited-members:
.. autoclass:: UniqueConstraint
:members:
:inherited-members:
.. _schema_indexes:
@@ -569,3 +576,4 @@ Index API
.. autoclass:: Index
:members:
:inherited-members:
+19 -9
View File
@@ -115,8 +115,7 @@ class DefaultDialect(interfaces.Dialect):
"""Optional set of argument specifiers for various SQLAlchemy
constructs, typically schema items.
To
implement, establish as a series of tuples, as in::
To implement, establish as a series of tuples, as in::
construct_arguments = [
(schema.Index, {
@@ -127,14 +126,25 @@ class DefaultDialect(interfaces.Dialect):
]
If the above construct is established on the Postgresql dialect,
the ``Index`` construct will now accept additional keyword arguments
such as ``postgresql_using``, ``postgresql_where``, etc. Any kind of
``postgresql_XYZ`` argument not corresponding to the above template will
be rejected with an ``ArgumentError`, for all those SQLAlchemy constructs
which implement the :class:`.DialectKWArgs` class.
the :class:`.Index` construct will now accept the keyword arguments
``postgresql_using``, ``postgresql_where``, nad ``postgresql_ops``.
Any other argument specified to the constructor of :class:`.Index`
which is prefixed with ``postgresql_`` will raise :class:`.ArgumentError`.
A dialect which does not include a ``construct_arguments`` member will
not participate in the argument validation system. For such a dialect,
any argument name is accepted by all participating constructs, within
the namespace of arguments prefixed with that dialect name. The rationale
here is so that third-party dialects that haven't yet implemented this
feature continue to function in the old way.
.. versionadded:: 0.9.2
.. seealso::
:class:`.DialectKWArgs` - implementing base class which consumes
:attr:`.DefaultDialect.construct_arguments`
The default is ``None``; older dialects which don't implement the argument
will have the old behavior of un-validated kwargs to schema/SQL constructs.
"""
+10 -3
View File
@@ -138,7 +138,14 @@ class _DialectArgDict(_DialectArgDictBase):
class DialectKWArgs(object):
"""Establish the ability for a class to have dialect-specific arguments
with defaults and validation.
with defaults and constructor validation.
The :class:`.DialectKWArgs` interacts with the
:attr:`.DefaultDialect.construct_arguments` present on a dialect.
.. seealso::
:attr:`.DefaultDialect.construct_arguments`
"""
@@ -153,7 +160,7 @@ class DialectKWArgs(object):
some_index = Index('a', 'b', mydialect_length=5)
The :meth:`.DialectKWArgs.argument_for` method is a per-argument
way adding extra arguments to the :attr:`.Dialect.construct_arguments`
way adding extra arguments to the :attr:`.DefaultDialect.construct_arguments`
dictionary. This dictionary provides a list of argument names accepted by
various schema-level constructs on behalf of a dialect.
@@ -164,7 +171,7 @@ class DialectKWArgs(object):
:param dialect_name: name of a dialect. The dialect must be locatable,
else a :class:`.NoSuchModuleError` is raised. The dialect must
also include an existing :attr:`.Dialect.construct_arguments` collection,
also include an existing :attr:`.DefaultDialect.construct_arguments` collection,
indicating that it participates in the keyword-argument validation and
default system, else :class:`.ArgumentError` is raised.
If the dialect does not include this collection, then any keyword argument