diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-03-11 21:45:57 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-03-11 21:45:57 +0000 |
| commit | 3f0252abc77399b20ab263c70d5ec328c405c525 (patch) | |
| tree | 8e7036a42de91d5846c4247eed96750109c54c50 /lib | |
| parent | bef0bb95e7372d63684bddbb30b461de877ae4db (diff) | |
| download | sqlalchemy-3f0252abc77399b20ab263c70d5ec328c405c525.tar.gz | |
- Fixed bug where column_prefix wasn't being checked before
not mapping an attribute that already had class-level
name present.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sqlalchemy/orm/mapper.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 98a027448..080540726 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -478,7 +478,7 @@ class Mapper(object): # pull properties from the inherited mapper if any. if self.inherits: for key, prop in self.inherits._props.iteritems(): - if key not in self._props and not self._should_exclude(key, local=False): + if key not in self._props and not self._should_exclude(key, key, local=False): self._adapt_inherited_property(key, prop, False) # create properties for each column in the mapped table, @@ -487,11 +487,11 @@ class Mapper(object): if column in self._columntoproperty: continue - if self._should_exclude(column.key, local=self.local_table.c.contains_column(column)): - continue - column_key = (self.column_prefix or '') + column.key + if self._should_exclude(column.key, column_key, local=self.local_table.c.contains_column(column)): + continue + # adjust the "key" used for this column to that # of the inheriting mapper for mapper in self.iterate_to_root(): @@ -509,7 +509,7 @@ class Mapper(object): col = self.polymorphic_on else: dont_instrument = False - if self._should_exclude(col.key, local=False): + if self._should_exclude(col.key, col.key, local=False): raise sa_exc.InvalidRequestError("Cannot exclude or override the discriminator column %r" % col.key) self._configure_property(col.key, ColumnProperty(col, _no_instrument=dont_instrument), init=False, setparent=True) @@ -937,7 +937,7 @@ class Mapper(object): def _is_userland_descriptor(self, obj): return not isinstance(obj, (MapperProperty, attributes.InstrumentedAttribute)) and hasattr(obj, '__get__') - def _should_exclude(self, name, local): + def _should_exclude(self, name, assigned_name, local): """determine whether a particular property should be implicitly present on the class. This occurs when properties are propagated from an inherited class, or are @@ -948,12 +948,12 @@ class Mapper(object): # check for descriptors, either local or from # an inherited class if local: - if self.class_.__dict__.get(name, None)\ - and self._is_userland_descriptor(self.class_.__dict__[name]): + if self.class_.__dict__.get(assigned_name, None)\ + and self._is_userland_descriptor(self.class_.__dict__[assigned_name]): return True else: - if getattr(self.class_, name, None)\ - and self._is_userland_descriptor(getattr(self.class_, name)): + if getattr(self.class_, assigned_name, None)\ + and self._is_userland_descriptor(getattr(self.class_, assigned_name)): return True if (self.include_properties is not None and |
