Hi Mike,
thank you so much for this insight into your way of tracing this, and for
the provided work-around (which I could really have come up with myself…).
3. next I want to whack the monkeypatched thing, because that's a lot of
> code that I don't want to be involved in the issue. Fortunately, just
> taking it out, behavior still reproduces. This means it's not part of
> the issue.
>
Yeah, it was unnecessary in the example. Sorry.
>
> 8. Where do we get a Tag() from? Weird, there is no call to Tag()
> anywhere at all. Is this relying on some behavior of association proxy?
> The only assocs that could do this are the tag_key and
> tag_value...but....which one sets up Tag()? I have no idea how the
> association proxy handles this.
>
> 9. after testing a few things (is it creating two Tag() objects for each
> one? it's not. changing order of attributes affects it? not really)
> it looks like I still don't know why value is set or not.
>
>
> 10. Well let's at least confirm this is where the issue originates:
>
> tags = association_proxy("elements_tags", "tag_value",
> creator=lambda k, v:
> ElementsTags(tag=Tag(key=k, value=v)))
>
> that is, don't try to challenge the association proxy to work in
> multiple levels of nesting, just keep it simple. bug is gone. OK, so
> association proxy definitely tripping up on setting up via two
> association proxies inside the constructor of another (not too
> surprising). We know it isn't creating two Tag objects. So, assoc
> proxy just doesn't want to set "value" sometimes.
>
Hmm. OK. Let me point out once more that this scheme is copied verbatim
from the official SQLAlchemy documentation:
http://docs.sqlalchemy.org/en/latest/orm/extensions/associationproxy.html#composite-association-proxies
. The difference is that the key attribute (special_key in the example from
the documentaiton) is also proxied. So I guess it is something with
aligning a list of the keys with the list of values, or something (mind
you: setting the *value* breaks when the *key* is another proxy!)… No idea,
but the way the proxy is set up comes from the docs.
For now, I just changed the code to your proposed work-around. I will see
what I can do for debugging the cause of the issue.
Cheers,
Nik
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.