current lazyloader isnt detecting null PKs

Issue #803 resolved
Former user created an issue

I noticed when I have a one to one relationship, and the foreign key is NULL, and I access the related object, SA runs the query for FK=NULL.

ie, port.jack_id is None, but if I access port.jack, it selects from jack where id = NULL

Attached is a short program that shows the query being ran, sorry I do not know how to turn that into a proper test.

Comments (3)

  1. Mike Bayer repo owner

    the use_get clause in lazyload() needs to check for a null PK, slightly complex because the mapper defines what kind of PK is null. alternatively, maybe query.get() should be smart enough to check an incoming null ident. not sure why this issue doesn't exist in 0.3 (or does it ?) since the code for m2o lazy load is essentially the same.

  2. Log in to comment