]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
tweak for Table.create() not having a return value
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 21 Oct 2006 22:38:40 +0000 (22:38 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 21 Oct 2006 22:38:40 +0000 (22:38 +0000)
examples/vertical/vertical.py
lib/sqlalchemy/orm/mapper.py

index d4c8b9cae77e820da91045b83b59df7f4455e3ec..4f0f5a15c65289eec719c56560a27dcf014d58a5 100644 (file)
@@ -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.
index ba3f019b071d08664ce45109c09593c2fd47369c..575609d3cdc6ff99d34f0a7d9084e735bdb4811b 100644 (file)
@@ -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):