Yeah, of course, must have been the lack of caffeine as I said. (-:
> Unfortunately, join and friends are off use because SQLCompiler's
> get_from_clause() creates join conditions on dumb string template.
> I monkeypatched compiler's get_from_clause in connection.ops._cache.
> Now it calls original method saved under another name on compiler and
> after that replaces join condition with required one in one of data
> chunks.
>
> How do you think, will there be problems?
First, if you look at the extent of changes required to force the ORM
to solve your problem, a question that comes to mind: Was it worth the
effort? I mean, if it were me, I'd probably try to do something like
this only if I needed it quite often, like, half of the queries I make
require this or something like that, otherwise I'd just stick to a raw
query. And even then, it might be easier to just create a reusable raw
query factory, if you get what I mean... But, of course, I don't know
your app nor what problem you're dealing with, so I may be off by
miles.
Second, the mechanisms you're altering aren't part of the public API;
they may change between versions just like that. Though this doesn't
usually happen, I already had to make some changes in this area in my
branch and I'll definitely have to also modify the joining code in
question. All I'm saying is, once you go this route, you shouldn't be
surprised if stuff breaks upon upgrade.
Michal
No comments:
Post a Comment