OK, I was right, cascade_mappers is the culprit.  I have a few other tables that also have relations to the drawings table.  Before upgrading to 2.x, I'd set those relations up with cascade mappers.  Adding any one of those relations back causes the recursion error.  I can add the properties manually and it still works though.

-Dennis

Attached is a test that doesn't work.

I found that whether I use cascade mappers or define the property manually, it is this specific table that causes my problem.  I can use cascade mappers on other relations and they don't break the query.

The only difference between this table and the others that have relations with drawings, is that this table has a dual primary key.  I tried specifying primaryjoin=.... in the relation for the ratings table but that didn't change it.

Thoughts?

Thanks
Dennis
# import sqlalchemy.mods.threadlocal
from sqlalchemy import *
import logging
from cherrypy import config



dbVars={'host':'localhost','user':'dennis','passwd':'dennis','dbname':'drawings' }

# NOTE find way to set db url in config file
engine = create_engine ( 'postgres://%(user)s:%(passwd)[EMAIL PROTECTED](host)s/%(dbname)s' % dbVars );
# DRAWINGS
drawing = Table ( 'drawings', engine,
				Column ( 'id', Integer, primary_key=True )
				
				)

# PROFILE
profile = Table ( 'profile', engine,
                  Column ( 'id' , Integer, primary_key=True)
                  )

ratings=Table( 'ratings', engine,
				Column ( 'drawing_id', Integer, ForeignKey('drawings.id'), nullable=False, primary_key=True ),
				Column ( 'profile_id', Integer, ForeignKey('profile.id'),nullable=False,primary_key=True,index='ix_ratings_pid' ),
				Column ( 'rating', Integer, nullable=False ),
				Column ( 'rating_time', DateTime, PassiveDefault(func.now()),nullable=False,index='ix_ratings_rt'))
		
tags=Table ( 'tags', engine,
				Column ( 'id', Integer, primary_key=True,nullable=False ),
				Column ( 'name', VARCHAR(20), nullable=False,index='ix_tags_name' ),
				Column ( 'accepted', Boolean,PassiveDefault('true'),nullable=False),
				Column ( 'reviewed', Boolean,PassiveDefault('false'),nullable=False) )
				
drawing_tags = Table ( 'drawing_tags', engine,
				Column ( 'drawing_id', Integer, ForeignKey('drawings.id'),primary_key=True,nullable=False ),
				Column ( 'tag_id', Integer, ForeignKey('tags.id'), primary_key=True,nullable=False ) )

# data mappers

class Tag(object):
	pass

mapper(Tag,tags)

class Drawing(object):
    pass

mapper(Drawing,drawing,
	properties={		
		'tags':relation(Tag,secondary=drawing_tags,backref='drawings'),		
	}
	)

class Rating(object):
	pass
mapper(Rating,ratings,
	properties={'drawing':relation(Drawing,backref='ratings',primaryjoin=drawing.c.id==ratings.c.drawing_id)}
	)
	

s=create_session()
print s.query(Drawing).select_by(name='test')
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to