summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/attributes.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-07-23 18:22:06 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-07-23 18:22:06 -0400
commit65bdf245c6cfd4381f8463714fbec1880a950fbb (patch)
tree8ecbc4326e4379eb6c6dd964171a8686cc1be770 /lib/sqlalchemy/orm/attributes.py
parentee0f80b4f028e27f35ae851e37e4070a9179b2a1 (diff)
downloadsqlalchemy-65bdf245c6cfd4381f8463714fbec1880a950fbb.tar.gz
- [feature] ORM entities can be passed
to select() as well as the select_from(), correlate(), and correlate_except() methods, where they will be unwrapped into selectables. [ticket:2245]
Diffstat (limited to 'lib/sqlalchemy/orm/attributes.py')
-rw-r--r--lib/sqlalchemy/orm/attributes.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py
index 47349e64a..045a9465d 100644
--- a/lib/sqlalchemy/orm/attributes.py
+++ b/lib/sqlalchemy/orm/attributes.py
@@ -112,9 +112,11 @@ PASSIVE_ONLY_PERSISTENT = util.symbol("PASSIVE_ONLY_PERSISTENT",
)
-class QueryableAttribute(interfaces.PropComparator):
+class QueryableAttribute(interfaces._InspectionAttr, interfaces.PropComparator):
"""Base class for class-bound attributes. """
+ is_attribute = True
+
def __init__(self, class_, key, impl=None,
comparator=None, parententity=None,
of_type=None):
@@ -149,6 +151,10 @@ class QueryableAttribute(interfaces.PropComparator):
# TODO: conditionally attach this method based on clause_element ?
return self
+ @property
+ def expression(self):
+ return self.comparator.__clause_element__()
+
def __clause_element__(self):
return self.comparator.__clause_element__()
@@ -191,10 +197,7 @@ class QueryableAttribute(interfaces.PropComparator):
def property(self):
return self.comparator.property
-
-@inspection._inspects(QueryableAttribute)
-def _get_prop(source):
- return source.property
+inspection._self_inspects(QueryableAttribute)
class InstrumentedAttribute(QueryableAttribute):
"""Class bound instrumented attribute which adds descriptor methods."""