Storm has no ROW constructor
Bug #698344 reported by
Henning Eggers
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Storm |
Fix Released
|
Undecided
|
Henning Eggers |
Bug Description
Using storm 0.18 on postgresql 8.4 (aka Launchpad hacking ;).
I stumbled onto this when I used a subquery that returned a tuple of values, i.e. a "row".
I would have expected that the equivalent of this SQL code:
(t1.c1, t1.c2) IN (SELECT c3, c4 FROM t2)
is this:
In( (t1.c1, t1.c2), Select((t2.c3, t2.c4)) )
But storm breaks up the tuple and this code is generated AFAICS:
t1.c1, t1.c2 IN (SELECT c3, c4 FROM t2)
which breaks because of the missing parentheses.
Fortunately (t1.c1, t1.c2) is only short for ROW(t1.c1, t1.c2), called a row constructor. So a simple solution would be to provide such a constructor, so the code could be written as:
In( Row(t1.c1, t1.c2), Select((t2.c3, t2.c4)) )
Related branches
lp:~henninge/storm/bug-698344-row-constructor
- Gavin Panella: Approve
- Jamu Kakar (community): Approve
-
Diff: 31 lines (+10/-0)2 files modifiedstorm/expr.py (+5/-0)
tests/expr.py (+5/-0)
Changed in storm: | |
status: | New → Fix Committed |
milestone: | none → 0.19 |
Changed in storm: | |
assignee: | nobody → Henning Eggers (henninge) |
Changed in storm: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
You can solve this problem now with this code:
from storm.expr import Func
result = store.find(t1, In(Func("ROW", t1.c1, t1.c2), Select((t2.c3, t2.c4))))
You can trivially implement a Row expression with this code:
from storm.expr import NamedFunc
class Row(NamedFunc):
name = "ROW"
and then do:
result = store.find(t1, In(Row(t1.c1, t1.c2), Select((t2.c3, t2.c4))))
That said, this is probably still a bug that should be fixed.