From: Mike Bayer Date: Sun, 11 Jan 2009 16:45:45 +0000 (+0000) Subject: - 0.5.1 bump X-Git-Tag: rel_0_5_1~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7b3b9f559a0c0a5a1e3bd3df37696037607af3fc;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - 0.5.1 bump - modernized mapper()/no table exception - added __tablename__ exception to declarative since ppl keep complaining --- diff --git a/CHANGES b/CHANGES index bd9b9f36cc..7dbd893333 100644 --- 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. diff --git a/lib/sqlalchemy/__init__.py b/lib/sqlalchemy/__init__.py index f6b861a38c..8680568782 100644 --- a/lib/sqlalchemy/__init__.py +++ b/lib/sqlalchemy/__init__.py @@ -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 diff --git a/lib/sqlalchemy/ext/declarative.py b/lib/sqlalchemy/ext/declarative.py index 70488eb077..1b5dee975b 100644 --- a/lib/sqlalchemy/ext/declarative.py +++ b/lib/sqlalchemy/ext/declarative.py @@ -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) diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index fd23f5563d..96043972a7 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -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 diff --git a/test/ext/declarative.py b/test/ext/declarative.py index 748ee7f854..5d0cbe8981 100644 --- a/test/ext/declarative.py +++ b/test/ext/declarative.py @@ -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"""