Code review comment for lp:~lifeless/storm/with

Revision history for this message
James Henstridge (jamesh) wrote :

Here's my thoughts on what Gustavo is suggesting:

1. The user should be able to create an object that acts similar to a table class to use the feature. Something like:

   WithTable = ???
   result = store.find(Foo, Foo.bar == WithTable.bar, WithTable.baz = 42)
   print list(result)

The WithTable object would compile similar to a normal table, but note that it had been used in the state object. The compile function for Select() could then generate the WITH clause if any such tables have been referenced by the query.

Generating the bulk of the with clause could be delegated to the WithTable's compile routine by calling it with a different context.

2. How do we create a WithTable? It would need the following information:
 * an alias for this temporary table.
 * a list of the column names. Do we also want the column types?
 * a query object that generates the temporary table.

What would be the most convenient way to collect this together? Perhaps something similar to ResultSet.get_select() would be convenient: it takes a column list we might be able to get column names from and produces a query object, so all it needs is a name.

3. Recursive queries could easily be handled internally to the WithTable in this model.

« Back to merge proposal