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? On 1 июл, 01:35, Michal Petrucha <michal.petru...@ksp.sk> wrote: > On Thu, Jun 30, 2011 at 02:13:05PM -0700, peroksid wrote: > > Thank you, Michal, > > > Unfortunately, I need join condition, not a WHERE clause, which can be > > easily extended with extra() method arguments. > > It is not my bad mood, simply the same condition in WHERE and ON > > produces different effect. > > Hmm, could you please provide an example? (-: Don't know whether it's > the late night combined with lack of caffeine or something else but I > can't figure out the difference at the moment... > > > I think rather about some method which gets together whole SQL query. > > Currently I call join() on queryset's query to join my table with part > > of target join condition. > > I could take the query assembled by "assembler" method and replace the > > part of condition with an entire one. > > > It seems you know pretty much about Django ORM if you work on > > composite keys (great respect). > > Could you please hint me about this "assembler" method I babble about? > > Well, basically, the models.sql.query.Query.join method and friends > manage a list of joins which is then processed in > models.sql.compiler.SQLCompiler.get_from_clause. > > Anyway, in some cases it might be more reasonable to just write your > own query instead of fighting with the ORM to make it do what you > wanti at all cost. (-; Bear in mind that if you try to override these > deeply hidden mechanisms in your code, you'll have to keep in sync > with any internal changes and refactors. And I can assure you these > will happen in the foreseeable future. (-; > > Michal > > signature.asc > < 1KбПросмотретьЗагрузить -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.