On Apr 3, 2012, at 11:05 AM, Oltmans wrote:

> Greetings, I'm using SQLAlchemy 0.6 with Python 2.6
> 
> from common import alchemy_session
> from common.patient import Patient
> 
> patient = alchemy_session.query(Patient).filter(Patient.patientId ==
> 1).first()#this works
> patient = alchemy_session.query(Patient).filter(Patient.patientId ==
> 2).first()#this fails
> #with following error
> 
> sqlalchemy.exc.InvalidRequestError: SQL expression, column, or mapped
> entity exp
> ected - got '<class 'vi_pycommon.patient.Patient'>'
> 
> D:\integration-scripts
> \allendale_bone_joint>alchemy_session.query(Patient).filte
> r(Patient.patientId == 2).first()
> -----------------------
> 
> so if you notice this line didn't fail
> patient = alchemy_session.query(Patient).filter(Patient.patientId ==
> 1).first()
> 
> but next line did, which was
> patient = alchemy_session.query(Patient).filter(Patient.patientId ==
> 2).first()#this fails
> 
> So I'm actually really stumped as to why this second call is failing
> with that error. I am absolutely
> sure I'm doing something wrong here, so kindly let me know how can I
> fix this one

Looks like SQLA 0.7.1 from the stack trace.  Anyway the error indicates 
"Patient" is not mapped so this would suggest clear_mappers() is being called 
somewhere, as there aren't many paths to un-map a class besides that.  Or the 
identifier "Patient" is somehow changing.

The key here is to begin shrinking the program into a single-file test case 
that you can send here, and in the process of getting there you'll probably 
identify the single thing that makes the behavior change.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to