]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- 0.5.1 bump
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 11 Jan 2009 16:45:45 +0000 (16:45 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 11 Jan 2009 16:45:45 +0000 (16:45 +0000)
- modernized mapper()/no table exception
- added __tablename__ exception to declarative since ppl keep complaining

CHANGES
lib/sqlalchemy/__init__.py
lib/sqlalchemy/ext/declarative.py
lib/sqlalchemy/orm/mapper.py
test/ext/declarative.py

diff --git a/CHANGES b/CHANGES
index bd9b9f36cc3b73f78edc62ef7c1da7c4fc836f57..7dbd8933339e537120281737fcfba5083d0caede 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,13 @@
 CHANGES
 =======
 
+0.5.1
+========
+
+- orm
+    - Modernized the "no mapped table" exception and added a more
+      explicit __table__/__tablename__ exception to declarative.
+      
 - mysql
     - Added the missing keywords from MySQL 4.1 so they get escaped
       properly.
index f6b861a38ce2c1336255c313323cfec9d8c06f02..8680568782c5189d2313fe3064ebc30a656fa8b8 100644 (file)
@@ -106,6 +106,6 @@ from sqlalchemy.engine import create_engine, engine_from_config
 
 __all__ = sorted(name for name, obj in locals().items()
                  if not (name.startswith('_') or inspect.ismodule(obj)))
-__version__ = '0.5.0'
+__version__ = '0.5.1'
 
 del inspect, sys
index 70488eb07708fa4a7eaaf488ee3a8f027bf2a19a..1b5dee975b7139f5f0992112647acaa0ef322422 100644 (file)
@@ -361,6 +361,10 @@ def _as_declarative(cls, classname, dict_):
     else:
         mapper_cls = mapper
 
+    if not table and 'inherits' not in mapper_args:
+        raise exceptions.InvalidRequestError("Class %r does not have a __table__ or __tablename__ "
+                    "specified and does not inherit from an existing table-mapped class." % cls)
+        
     cls.__mapper__ = mapper_cls(cls, table, properties=our_stuff,
                                 **mapper_args)
 
index fd23f5563d69b4a545e4d589636053b386595706..96043972a7ba09adbf81bdd4bc709456f8c2086b 100644 (file)
@@ -281,9 +281,7 @@ class Mapper(object):
             self._identity_class = self.class_
 
         if self.mapped_table is None:
-            raise sa_exc.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.)" % self)
+            raise sa_exc.ArgumentError("Mapper '%s' does not have a mapped_table specified." % self)
 
     def _configure_extensions(self):
         """Go through the global_extensions list as well as the list
index 748ee7f8549afafb4be787d741771c7f70751872..5d0cbe89814ed27c2d072d0631aa1e8095d70346 100644 (file)
@@ -58,6 +58,12 @@ class DeclarativeTest(testing.TestBase, testing.AssertsExecutionResults):
         eq_(a1, Address(email='two'))
         eq_(a1.user, User(name='u1'))
 
+    def test_no_table(self):
+        def go():
+            class User(Base):
+                id = Column('id', Integer, primary_key=True)
+        self.assertRaisesMessage(sa.exc.InvalidRequestError, "does not have a __table__", go)
+        
     def test_recompile_on_othermapper(self):
         """declarative version of the same test in mappers.py"""