It should be possible to use a string when defining order_by for a ReferenceSet

Bug #580037 reported by Jamu Kakar
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Storm
Fix Released
Medium
Jamu Kakar

Bug Description

I want to define the order_by property of a ReferenceSet as a string
to work around circular dependencies. For example, this doesn't
work:

class Account(Storm):

    id = Int(primary=True)
    users = ReferenceSet(id, "User.account_id", order_by="User.name")

It doesn't work because the value passed to order_by is not handled
by the property resolver. It's stored and passed directly to
ResultSet.order_by which, in the case of a string, injects the value
directly into the generated SQL (which might even make it possible
to create a SQL injection attack). A hack workaround for the issue
is to use a Column expression:

class Account(Storm):

    id = Int(primary=True)
    users = ReferenceSet(id, "User.account_id",
                         order_by=Column("name", "user"))

Related branches

Jamu Kakar (jkakar)
Changed in storm:
assignee: nobody → Jamu Kakar (jkakar)
importance: Undecided → Medium
milestone: none → 0.17
Jamu Kakar (jkakar)
Changed in storm:
status: New → In Progress
Jamu Kakar (jkakar)
Changed in storm:
status: In Progress → Fix Committed
Jamu Kakar (jkakar)
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.