* Cédric Krier [2014-10-13 11:28:15 +0200]
I don't see how this does any recursion. Can you elaborate further?
Because defining an identifier that makes a reference to itself is
AFAIK only possible with a function.
> t = Table(…)
> q3 = t.select(…,
> where=t.id.in_(wq2),
> with=[wq1, wq2],
It should be an ordereddict because with queries must be named and
their order is important.
But indeed this example is better than mine.
> with_recursive=True)
>
>
> `With` will generate an alias automatically and will be of type
> `FromItem`.
In fact I already took that into account.
> I'm wondering if the with_recursive could not be automatically deduced
> from the sets of queries used but I think it will be very complicate and
> expensive.
Since I do not understand your example I can not comment.
To display more beautifully the recursion I though about using
functions but it's always ugly.
def recursive_query(recursive=False):
if recursive:
return Query
else:
return InitialQuery | recursive_query(True)
> Don't forget that `With` could take any `Query` type.
I did not tested it but it should work.
> Also I don't think we need a fast accessor on `Query` to return a `With`
> instance.
OK.
> Maybe a crazy idea but it could also be implemented to support this
> form:
>
> q1 = Table(…).select(…)
> q2 = Table(…).select(…)
> t = Table(…)
>
> with q1 as wq1, q2 as wq2:
> q3 = t.select(t.id.in_(wq2),
> with=[wq1, wq2],
> with_recursive=True)
>
> Of course the with statement is kind of useless except for formatting.
I don't see the point in the with neither.