On Fri, Aug 23, 2013 at 2:31 PM, Gombas, Gabor (IT) < gabor.gom...@morganstanley.com> wrote:
> On Fri, Aug 23, 2013 at 12:11:39PM -0700, Jonathan Vanasco wrote: > > > i think a simple fix could be something like this ( line 240, > sqlalchemy/ext/associationproxy.py > > ) > > > > if self.scalar: > > - if not getattr(obj, self.target_collection) > > - return self._scalar_get(getattr(obj, > self.target_collection)) > > else: > > > > if self.scalar: > > + proxied = getattr(obj, self.target_collection) > > + if not proxied : > > + return None > > + return self._scalar_get(proxied) > > else: > > We're monkey-patching AssociationProxy.__get__ with the same change > since SQLA 0.5.x, so it would be nice to get it applied upstream... > Maybe in 0.9? > The patch seems like surprising Python behavior to me. Traversing across a None is almost certainly a bug in regular code, and quashing that error by default feels dangerous. I would want this to raise by default (and I have found bugs because it did.) I think you could opt into this behavior by supplying an alternate, custom getter function that quashed None when creating the proxy. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/groups/opt_out.