mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-06-06 07:45:30 -04:00
- relation() can accept a callable for its first argument,
which returns the class to be related. This is in place to assist declarative packages to define relations without classes yet being in place.
This commit is contained in:
@@ -77,7 +77,12 @@ CHANGES
|
||||
|
||||
- deprecated Query methods apply_sum(), apply_max(), apply_min(),
|
||||
apply_avg(). Better methodologies are coming....
|
||||
|
||||
|
||||
- relation() can accept a callable for its first argument,
|
||||
which returns the class to be related. This is in place
|
||||
to assist declarative packages to define relations without
|
||||
classes yet being in place.
|
||||
|
||||
- Added a new "higher level" operator called "of_type()": used
|
||||
in join() as well as with any() and has(), qualifies the
|
||||
subclass which will be used in filter criterion, e.g.:
|
||||
|
||||
@@ -468,6 +468,9 @@ class PropertyLoader(StrategizedProperty):
|
||||
self.mapper = mapper.class_mapper(self.argument, entity_name=self.entity_name, compile=False)
|
||||
elif isinstance(self.argument, mapper.Mapper):
|
||||
self.mapper = self.argument
|
||||
elif callable(self.argument):
|
||||
# accept a callable to suit various deferred-configurational schemes
|
||||
self.mapper = mapper.class_mapper(self.argument(), entity_name=self.entity_name, compile=False)
|
||||
else:
|
||||
raise exceptions.ArgumentError("relation '%s' expects a class or a mapper argument (received: %s)" % (self.key, type(self.argument)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user