From 431149d54284c161e03166eeddc7deefdf2f0520 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 21 Oct 2006 22:38:40 +0000 Subject: [PATCH] tweak for Table.create() not having a return value --- examples/vertical/vertical.py | 8 +++++--- lib/sqlalchemy/orm/mapper.py | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/vertical/vertical.py b/examples/vertical/vertical.py index d4c8b9cae7..4f0f5a15c6 100644 --- a/examples/vertical/vertical.py +++ b/examples/vertical/vertical.py @@ -13,7 +13,7 @@ e = BoundMetaData('sqlite://', echo=True) entities = Table('entities', e, Column('entity_id', Integer, primary_key=True), Column('title', String(100), nullable=False), - ).create() + ) # this table represents dynamic fields that can be associated # with values attached to an Entity. @@ -21,7 +21,7 @@ entities = Table('entities', e, entity_fields = Table('entity_fields', e, Column('field_id', Integer, primary_key=True), Column('name', String(40), nullable=False), - Column('datatype', String(30), nullable=False)).create() + Column('datatype', String(30), nullable=False)) # this table represents attributes that are attached to an # Entity object. It combines a row from entity_fields with an actual value. @@ -34,7 +34,9 @@ entity_values = Table('entity_values', e, Column('int_value', Integer), Column('string_value', String(500)), Column('binary_value', PickleType), - Column('datetime_value', DateTime)).create() + Column('datetime_value', DateTime)) + +e.create_all() class EntityDict(dict): """this is a dictionary that implements an append() and an __iter__ method. diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index ba3f019b07..575609d3cd 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -358,7 +358,10 @@ class Mapper(object): self.mapped_table = self.local_table if self.polymorphic_identity is not None: self._add_polymorphic_mapping(self.polymorphic_identity, self) - + + if self.mapped_table is None: + raise exceptions.ArgumentError("Mapper '%s' does not have a mapped_table specified. (Are you using the return value of table.create()? It no longer has a return value.)" % str(self)) + # convert polymorphic class associations to mappers for key in self.polymorphic_map.keys(): if isinstance(self.polymorphic_map[key], type): -- 2.47.2