]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
add a really contrived test that tests the _already_compiling flag. but this seems...
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 14 Aug 2009 16:54:49 +0000 (16:54 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 14 Aug 2009 16:54:49 +0000 (16:54 +0000)
so far.

test/orm/test_mapper.py

index c34ccdbab852b6def978bceb2a6a86f71236c227..597b0bd566bde5b681019c2f67389d6a50ffda21 100644 (file)
@@ -891,6 +891,24 @@ class MapperTest(_fixtures.FixtureTest):
         eq_(str((User.name.intersects('ed')).compile(dialect=sa.engine.default.DefaultDialect())), "users.name &= :name_1")
         
 
+    @testing.resolve_artifact_names
+    def test_reentrant_compile(self):
+        # this trips the _already_compiling
+        # flag in mapper.compile().  but if the m2.compile is 
+        # changed to m1.compile, you still get a stack overflow.
+        # not sure why the previous use case did it that way (i.e. 
+        # it was declarative compiling a mapper within ForeignKey()).
+        class MyFakeProperty(sa.orm.properties.ColumnProperty):
+            def post_instrument_class(self, mapper):
+                super(MyFakeProperty, self).post_instrument_class(mapper)
+                m2.compile()
+            
+        m1 = mapper(User, users, properties={
+            'name':MyFakeProperty(users.c.name)
+        })
+        m2 = mapper(Address, addresses)
+        compile_mappers()
+        
     @testing.resolve_artifact_names
     def test_reconstructor(self):
         recon = []