summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-07-20 01:00:30 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-07-20 01:00:30 +0000
commit0b7557a30a94b38c816499dc7e854214120b68cf (patch)
tree76c481b59eef962614634b236e4dbb40334b869a /lib/sqlalchemy
parent98fb8894e3214fa01e2cfe5e83de5ff8d2c6fe3e (diff)
downloadsqlalchemy-0b7557a30a94b38c816499dc7e854214120b68cf.tar.gz
fixed [ticket:245]rel_0_2_6
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/mapper.py7
-rw-r--r--lib/sqlalchemy/orm/properties.py5
-rw-r--r--lib/sqlalchemy/orm/query.py7
3 files changed, 14 insertions, 5 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py
index 8c8ce4cff..7cc99b225 100644
--- a/lib/sqlalchemy/orm/mapper.py
+++ b/lib/sqlalchemy/orm/mapper.py
@@ -76,6 +76,7 @@ class Mapper(object):
self.always_refresh = always_refresh
self.version_id_col = version_id_col
self.concrete = concrete
+ self.single = False
self.inherits = inherits
self.select_table = select_table
self.local_table = local_table
@@ -230,6 +231,7 @@ class Mapper(object):
# inherit_condition is optional.
if self.local_table is None:
self.local_table = self.inherits.local_table
+ self.single = True
if not self.local_table is self.inherits.local_table:
if self.concrete:
self._synchronizer= None
@@ -348,7 +350,7 @@ class Mapper(object):
self.inherits._inheriting_mappers.add(self)
for key, prop in self.inherits.__props.iteritems():
if not self.__props.has_key(key):
- p = prop.adapt_to_inherited(key, self)
+ prop.adapt_to_inherited(key, self)
# load properties from the main table object,
# not overriding those set up in the 'properties' argument
@@ -539,7 +541,7 @@ class Mapper(object):
prop.init(key, self)
for mapper in self._inheriting_mappers:
- p = prop.adapt_to_inherited(key, mapper)
+ prop.adapt_to_inherited(key, mapper)
def __str__(self):
return "Mapper|" + self.class_.__name__ + "|" + (self.entity_name is not None and "/%s" % self.entity_name or "") + str(self.local_table)
@@ -1133,7 +1135,6 @@ class MapperProperty(object):
p.localparent = newparent
p.parent = self.parent
p.inherits = getattr(self, 'inherits', self)
- return p
def do_init(self):
"""template method for subclasses"""
pass
diff --git a/lib/sqlalchemy/orm/properties.py b/lib/sqlalchemy/orm/properties.py
index 6b3bb7883..c34b0223a 100644
--- a/lib/sqlalchemy/orm/properties.py
+++ b/lib/sqlalchemy/orm/properties.py
@@ -48,6 +48,11 @@ class ColumnProperty(mapper.MapperProperty):
# set a scalar object instance directly on the object,
# bypassing SmartProperty event handlers.
instance.__dict__[self.key] = row[self.columns[0]]
+ def adapt_to_inherited(self, key, newparent):
+ if newparent.concrete:
+ return
+ else:
+ super(ColumnProperty, self).adapt_to_inherited(key, newparent)
def __repr__(self):
return "ColumnProperty(%s)" % repr([str(c) for c in self.columns])
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index 8e87ac09a..268273990 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -18,7 +18,6 @@ class Query(object):
else:
self.mapper = class_or_mapper.compile()
self.mapper = self.mapper.get_select_mapper().compile()
-
self.always_refresh = kwargs.pop('always_refresh', self.mapper.always_refresh)
self.order_by = kwargs.pop('order_by', self.mapper.order_by)
self.extension = kwargs.pop('extension', self.mapper.extension)
@@ -317,7 +316,10 @@ class Query(object):
if order_by is False:
if self.table.default_order_by() is not None:
order_by = self.table.default_order_by()
-
+
+ if self.mapper.single and self.mapper.polymorphic_on is not None and self.mapper.polymorphic_identity is not None:
+ whereclause = sql.and_(whereclause, self.mapper.polymorphic_on==self.mapper.polymorphic_identity)
+
if self._should_nest(**kwargs):
from_obj.append(self.table)
@@ -366,5 +368,6 @@ class Query(object):
# give all the attached properties a chance to modify the query
for key, value in self.mapper.props.iteritems():
value.setup(key, statement, **kwargs)
+
return statement