summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/descriptor_props.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-08-13 19:45:34 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-08-13 19:45:34 -0400
commit7fc08fe89af9760750899346cf81bd74e0d9150f (patch)
treed1a9c485c7795bf33bda15900411aefcec91d193 /lib/sqlalchemy/orm/descriptor_props.py
parentea85c7053dc9532a95fd487628768fdfc1ca5c30 (diff)
downloadsqlalchemy-7fc08fe89af9760750899346cf81bd74e0d9150f.tar.gz
- The ``info`` parameter has been added to the constructor for
:class:`.SynonymProperty` and :class:`.ComparableProperty`. - The ``info`` parameter has been added as a constructor argument to all schema constructs including :class:`.MetaData`, :class:`.Index`, :class:`.ForeignKey`, :class:`.ForeignKeyConstraint`, :class:`.UniqueConstraint`, :class:`.PrimaryKeyConstraint`, :class:`.CheckConstraint`. fixes #2963
Diffstat (limited to 'lib/sqlalchemy/orm/descriptor_props.py')
-rw-r--r--lib/sqlalchemy/orm/descriptor_props.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/descriptor_props.py b/lib/sqlalchemy/orm/descriptor_props.py
index 5ed24b8c0..f0f9a6468 100644
--- a/lib/sqlalchemy/orm/descriptor_props.py
+++ b/lib/sqlalchemy/orm/descriptor_props.py
@@ -496,7 +496,7 @@ class SynonymProperty(DescriptorProperty):
def __init__(self, name, map_column=None,
descriptor=None, comparator_factory=None,
- doc=None):
+ doc=None, info=None):
"""Denote an attribute name as a synonym to a mapped property,
in that the attribute will mirror the value and expression behavior
of another attribute.
@@ -531,6 +531,11 @@ class SynonymProperty(DescriptorProperty):
conjunction with the ``descriptor`` argument in order to link a
user-defined descriptor as a "wrapper" for an existing column.
+ :param info: Optional data dictionary which will be populated into the
+ :attr:`.InspectionAttr.info` attribute of this object.
+
+ .. versionadded:: 1.0.0
+
:param comparator_factory: A subclass of :class:`.PropComparator`
that will provide custom comparison behavior at the SQL expression
level.
@@ -556,6 +561,8 @@ class SynonymProperty(DescriptorProperty):
self.descriptor = descriptor
self.comparator_factory = comparator_factory
self.doc = doc or (descriptor and descriptor.__doc__) or None
+ if info:
+ self.info = info
util.set_creation_order(self)
@@ -608,7 +615,8 @@ class SynonymProperty(DescriptorProperty):
class ComparableProperty(DescriptorProperty):
"""Instruments a Python property for use in query expressions."""
- def __init__(self, comparator_factory, descriptor=None, doc=None):
+ def __init__(
+ self, comparator_factory, descriptor=None, doc=None, info=None):
"""Provides a method of applying a :class:`.PropComparator`
to any Python descriptor attribute.
@@ -670,10 +678,17 @@ class ComparableProperty(DescriptorProperty):
The like-named descriptor will be automatically retrieved from the
mapped class if left blank in a ``properties`` declaration.
+ :param info: Optional data dictionary which will be populated into the
+ :attr:`.InspectionAttr.info` attribute of this object.
+
+ .. versionadded:: 1.0.0
+
"""
self.descriptor = descriptor
self.comparator_factory = comparator_factory
self.doc = doc or (descriptor and descriptor.__doc__) or None
+ if info:
+ self.info = info
util.set_creation_order(self)
def _comparator_factory(self, mapper):