Storm has no ROW constructor

Bug #698344 reported by Henning Eggers
6
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

Revision history for this message
Jamu Kakar (jkakar) wrote :

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.

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

I agree with Jamu. Given that we're miscompiling the expression, it'd be better to fix that issue.

Revision history for this message
Henning Eggers (henninge) wrote :

I linked a branch with a fix. I also created an MP. Anything else I need to do to get this merged?

Revision history for this message
Jamu Kakar (jkakar) wrote :

I suggested Henning push a branch with a Row expression since I
thought it'd be generally useful. Perhaps, when we fix the real
underlying bug, it won't be particularly necessary... but in general I
think it's not a bad thing to have expressions for builtin functions
available out-of-the-box.

So even though the addition of the Row expression isn't an acceptable
fix for the problem, I think it's a useful addition to Storm.

Gavin Panella (allenap)
Changed in storm:
status: New → Fix Committed
milestone: none → 0.19
Changed in storm:
assignee: nobody → Henning Eggers (henninge)
Barry Warsaw (barry)
Changed in storm:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.