select results randomisation

Bug #94983 reported by James Henstridge
4
Affects Status Importance Assigned to Milestone
Storm
New
Medium
Unassigned

Bug Description

One feature that has been very helpful for Launchpad development is the ability to tell the ORM to randomise the ordering of the results of a SELECT query (still subject to the ordering requested). This prevents people from writing tests that rely on the natural ordering of a result set, which is usually consistent for testing but not so in produciton.

We currently implement this in sqlobject by extending the list of "ORDER BY" clauses to end with "RANDOM()", which achieves the desired results with PostgreSQL. We only turn this on when running the test suite because the additional sorting would be a performance problem with the larger data set used in production.

It'd be nice to maintain this feature when we move to Storm.

Related branches

Changed in storm:
importance: Undecided → Medium
Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

Looks nice and simple. I just wonder about the way that result randomization is enabled. Having
a method on the Store means that we'll have to call it on all the stores we create, which sounds
good when we want isolation between stores, but at the same time I wonder how we'll enable
it for debugging in a practical way. Specifically for the use case you mention, having an
environment variable might be an easier way to enable it.

What do you think?

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

I am not particularly happy with the API in the branch myself. A global option (similar to storm.tracer.debug()?) would probably be better. Where do you think would be a good place to expose such a toggle?

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

What do you think of using an environment variable instead? This sounds like a simple way
to handle the test suite case, which is probably the most interesting use case we have for it.

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.