Message2101
I have a class (user) with a link to itself
(supervisor). If I now group by supervisor I get a
database exception because the _user table is used
twice in the generated SQL query (backend is postgresql
but this the code is the same for mysql)
Exception:
psycopg.ProgrammingError: ERROR: table name "_user"
specified more than once select
_user.id,_user._username,_user._lastname from _user
LEFT OUTER JOIN _user on _user._supervisor=_user.id
where ((_user._status in ('1'))) and _user.__retired__
<> 1 order by _user._username,_user._lastname
The solution is to alias the right hand side of the
LEFT OUTER JOIN:
- loj.append('LEFT OUTER JOIN %s
on %s=%s.id'%(tn,
- o, tn))
- o = tn + '._%s'%op
+ loj.append('LEFT OUTER JOIN %s
as rhs_ on %s=rhs_.id'
+ %(tn, o))
+ o = 'rhs_._%s'%op
Patch attached for rdbms_common and back_mysql (they
use much of redundant code...). Note that the patch is
relative to my previous changes in the feature request:
https://sourceforge.net/tracker/index.php?func=detail&aid=1379534&group_id=31577&atid=402791
but the bug is present in original 0.8.4 code, too.
|
|
Date |
User |
Action |
Args |
2009-02-03 14:21:33 | admin | link | issue1404930 messages |
2009-02-03 14:21:33 | admin | create | |
|