diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-04-06 12:44:35 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-04-06 12:44:35 -0400 |
| commit | 33e084532f22d9c12537c817fab908f38b4614a7 (patch) | |
| tree | a1a0ffdf1be6abbdaaa4c7cd7e018190cbe78e58 /test | |
| parent | 04a814f97bd2793ef62f3becb93e840d09bf3ad8 (diff) | |
| parent | e9cdc0b86ebae7463d33383b9a7e2706387fc6cf (diff) | |
| download | sqlalchemy-33e084532f22d9c12537c817fab908f38b4614a7.tar.gz | |
merge default
Diffstat (limited to 'test')
| -rw-r--r-- | test/ext/test_declarative.py | 48 | ||||
| -rw-r--r-- | test/sql/test_types.py | 4 |
2 files changed, 52 insertions, 0 deletions
diff --git a/test/ext/test_declarative.py b/test/ext/test_declarative.py index 0b1f74f67..67e650c34 100644 --- a/test/ext/test_declarative.py +++ b/test/ext/test_declarative.py @@ -2052,7 +2052,55 @@ class DeclarativeMixinTest(DeclarativeTestBase): id = Column(Integer, primary_key=True) eq_(MyModel.__table__.kwargs,{'mysql_engine': 'InnoDB'}) + + def test_mapper_args_classproperty(self): + class ComputedMapperArgs: + @classproperty + def __mapper_args__(cls): + if cls.__name__=='Person': + return dict(polymorphic_on=cls.discriminator) + else: + return dict(polymorphic_identity=cls.__name__) + + class Person(Base,ComputedMapperArgs): + __tablename__ = 'people' + id = Column(Integer, primary_key=True) + discriminator = Column('type', String(50)) + + class Engineer(Person): + pass + + compile_mappers() + + assert class_mapper(Person).polymorphic_on is Person.__table__.c.type + eq_(class_mapper(Engineer).polymorphic_identity, 'Engineer') + def test_mapper_args_classproperty_two(self): + # same as test_mapper_args_classproperty, but + # we repeat ComputedMapperArgs on both classes + # for no apparent reason. + + class ComputedMapperArgs: + @classproperty + def __mapper_args__(cls): + if cls.__name__=='Person': + return dict(polymorphic_on=cls.discriminator) + else: + return dict(polymorphic_identity=cls.__name__) + + class Person(Base,ComputedMapperArgs): + __tablename__ = 'people' + id = Column(Integer, primary_key=True) + discriminator = Column('type', String(50)) + + class Engineer(Person, ComputedMapperArgs): + pass + + compile_mappers() + + assert class_mapper(Person).polymorphic_on is Person.__table__.c.type + eq_(class_mapper(Engineer).polymorphic_identity, 'Engineer') + def test_table_args_composite(self): class MyMixin1: diff --git a/test/sql/test_types.py b/test/sql/test_types.py index 2186d47d2..fb9b3912a 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -884,6 +884,9 @@ class ExpressionTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL): expr = column('bar', Integer) - 3 eq_(expr.type._type_affinity, Integer) + + expr = bindparam('bar') + bindparam('foo') + eq_(expr.type, types.NULLTYPE) def test_distinct(self): s = select([distinct(test_table.c.avalue)]) @@ -894,6 +897,7 @@ class ExpressionTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL): assert distinct(test_table.c.data).type == test_table.c.data.type assert test_table.c.data.distinct().type == test_table.c.data.type + class DateTest(TestBase, AssertsExecutionResults): @classmethod |
