Hi,
On Tue, 22 Mar 2011 12:01:54 +0300
Oleg Broytman <ph...@ph...> wrote:
> Hi!
>
> On Tue, Mar 22, 2011 at 09:27:04AM +0100, Gregor Horvath wrote:
> > def IN_(item, list_):
> > if isinstance(list_, SelectResults):
> > list_ = Select([list_.sourceClass.q.id],
> > where=list_.clause,
> > join=list_.ops.get('join', NoDefault),
> > distinct=list_.ops.get('distinct',False),
> > lazyColumns=list_.ops.get('lazyColumns',
> > False), start=list_.ops.get('start', 0),
> > end=list_.ops.get('end', None),
> > orderBy=list_.ops.get('dbOrderBy',
> > NoDefault), reversed=list_.ops.get('reversed', False),
> > staticTables=list_.tables,
> > forUpdate=list_.ops.get('forUpdate', False))
>
> Isn't this just
>
> query = list_.queryForSelect()
> query.ops['items'] = [list_.sourceClass.q.id]
>
>
Thank You. Yes this is equivalent and more compact.
But I would prefer to make an optional argument 'columns' to
queryForSelect, because it is not obvious that the columns / items can
be changed after initialisation.
so it would be
list_ = list_.queryForSelect(columns=[list_.sourceClass.q.id])
--
Gregor
|