Merge lp:~allenap/storm/get-set-expr-columns into lp:storm
Proposed by
Gavin Panella
Status: | Work in progress |
---|---|
Proposed branch: | lp:~allenap/storm/get-set-expr-columns |
Merge into: | lp:storm |
Prerequisite: | lp:~allenap/storm/value-columns-by-name |
Diff against target: |
75 lines (+35/-1) 3 files modified
storm/expr.py (+14/-0) tests/expr.py (+10/-0) tests/store/base.py (+11/-1) |
To merge this branch: | bzr merge lp:~allenap/storm/get-set-expr-columns |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Henstridge | Needs Fixing | ||
Review via email:
|
Commit message
ResultSet.values() can now return values from set expressions.
Description of the change
Enables ResultSet.values() to operate on set expressions. It does this with a pass-through property, SetExpr.columns. An alternative implementation could be to deal specially with SetExprs in values() itself.
To post a comment you must log in.
Unmerged revisions
- 358. By Gavin Panella
-
Tests to show ResultSet.values() working on a set expression.
- 357. By Gavin Panella
-
Create a pass-through columns property on SetExpr.
- 356. By Gavin Panella
-
ResultSet.values() can now accept column names as well as columns themselves.
In most cases, I've used the replace_columns() helper in the store code where I need to fiddle with the column list for a query.
It'd probably be better to do the same in ResultSet.values(). The current code looks like it could leak changes outside of the method call, which could be problematic.
Secondly, I don't believe this patch will result in correct behaviour from ResultSet.values() for set expressions. Consider a table Foo containing the following data:
id | name
---+------
10 | value
20 | value
And then do the following:
result = store.find(Foo, id=10). union(store. find(Foo, id=20)) values( Foo.name) )
print list(result.
This will print ['value'] when it should print ['value', 'value']. The result set clearly has two rows, but if we rewrite the column lists to Foo.name then the union will only give us one row.