diff options
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r-- | lib/sqlalchemy/ext/declarative/base.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/sqlalchemy/ext/declarative/base.py b/lib/sqlalchemy/ext/declarative/base.py index e5bc670b3..f1d75bb4b 100644 --- a/lib/sqlalchemy/ext/declarative/base.py +++ b/lib/sqlalchemy/ext/declarative/base.py @@ -303,6 +303,11 @@ class _MapperConfig(object): if isinstance(ret, (Column, MapperProperty)) and \ ret.doc is None: ret.doc = obj.__doc__ + # here, the attribute is some other kind of property that + # we assume is not part of the declarative mapping. + # however, check for some more common mistakes + else: + self._warn_for_decl_attributes(base, name, obj) if inherited_table_args and not tablename: table_args = None @@ -311,6 +316,14 @@ class _MapperConfig(object): self.tablename = tablename self.mapper_args_fn = mapper_args_fn + def _warn_for_decl_attributes(self, cls, key, c): + if isinstance(c, expression.ColumnClause): + util.warn( + "Attribute '%s' on class %s appears to be a non-schema " + "'sqlalchemy.sql.column()' " + "object; this won't be part of the declarative mapping" % + (key, cls)) + def _produce_column_copies(self, base): cls = self.cls dict_ = self.dict_ @@ -382,6 +395,7 @@ class _MapperConfig(object): # and place the evaluated value onto the class. if not k.startswith('__'): dict_.pop(k) + self._warn_for_decl_attributes(cls, k, value) if not late_mapped: setattr(cls, k, value) continue |