I've just committed two revisions (727 and 728) that implement new major
feature - allow to join a table with itself using aliases. The main code
is in sqlbuilder.py, classes AliasField, AliasTable and Alias. A user
only needs Alias. Usage:
alias = Alias(MyTable)
MyTable.select(MyTable.q.name == alias.q.parent)
One can name the alias:
alias = Alias(MyTable, "my_table_alias")
In the absence of the name Alias will generate a name using thread-safe
global counter.
Aliases can be used with JOINS. In the revision 728 I've also
committed some documentation, examples and FAQs for JOINs and aliases.
Though aliases is a really major feature, design and implementation
are quick-and-dirty. Certainly there are bugs and big stones to stumble
upon. But I need them in my commercial program, so I implemented them
the way they are now.
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ phd@...
Programmers don't die, they just GOSUB without RETURN.
|