(i.e. column-based mapped class attributes) as column
arguments. [ticket:1214]
+ - Column with no name (as in declarative) won't raise a
+ NoneType error when it's string output is requsted
+ (such as in a stack trace).
+
- declarative
- Can now specify Column objects on subclasses which have no
table of their own (i.e. use single table inheritance).
column.key = key
if column.name is None:
column.name = key
+ util.reset_memoized(column, 'description')
\ No newline at end of file
else:
return self.description
+ @util.memoized_property
+ def description(self):
+ if not self.name:
+ return "(no name)"
+ else:
+ return self.name.encode('ascii', 'backslashreplace')
+
+ @property
def bind(self):
return self.table.bind
- bind = property(bind)
def references(self, column):
"""Return True if this Column references the given column via foreign key."""
class User(Base):
id = Column('id', Integer, primary_key=True)
self.assertRaisesMessage(sa.exc.InvalidRequestError, "does not have a __table__", go)
+
+ def test_undefer_column_name(self):
+ # TODO: not sure if there was an explicit
+ # test for this elsewhere
+ foo = Column(Integer)
+ eq_(str(foo), '(no name)')
+ eq_(foo.key, None)
+ eq_(foo.name, None)
+ decl._undefer_column_name('foo', foo)
+ eq_(str(foo), 'foo')
+ eq_(foo.key, 'foo')
+ eq_(foo.name, 'foo')
def test_recompile_on_othermapper(self):
"""declarative version of the same test in mappers.py"""