other mapped attribute, including filter expressions,
get/set operations, etc.::
- address = session.query(EmailAddress).filter(EmailAddress.email == 'some address').one()
+ address = session.query(EmailAddress).\\
+ filter(EmailAddress.email == 'some address').\\
+ one()
address.email = 'some other address'
- session.flush()
-
- q = session.query(EmailAddress).filter_by(email='some other address')
+ session.commit()
-If the mapped class does not provide a property, the :func:`.synonym` construct will create a default getter/setter object automatically.
+ q = session.query(EmailAddress).\
+ filter_by(email='some other address')
-To use synonyms with :mod:`~sqlalchemy.ext.declarative`, see the section
-:ref:`declarative_synonyms`.
+ Note that the "synonym" feature is eventually to be replaced by the superior
+ "hybrid attributes" approach, slated to become a built in feature of SQLAlchemy
+ in a future release. "hybrid" attributes are simply Python properties that evaulate
+ at both the class level and at the instance level. For an example of their usage,
+ see the :mod:`derived_attributes` example.
+
.. _custom_comparators:
Custom Comparators
def _is_userland_descriptor(self, obj):
return not isinstance(obj,
- (MapperProperty, attributes.InstrumentedAttribute)) and \
- hasattr(obj, '__get__')
+ (MapperProperty, attributes.QueryableAttribute)) and \
+ hasattr(obj, '__get__') and not \
+ isinstance(obj.__get__(None, obj),
+ attributes.QueryableAttribute)
+
- def _should_exclude(self, name, assigned_name, local):
+
+ def _should_exclude(self, name, assigned_name, local, column):
"""determine whether a particular property should be implicitly
present on the class.