[storm] Do aggregate queries in storm imply an ORDER BY?
James Henstridge
james at jamesh.id.au
Sat Jun 20 04:26:31 BST 2009
On Sat, Jun 20, 2009 at 3:08 AM, Jason Baker<jbaker at zeomega.com> wrote:
> There's one test in tests/store/base.py that I'm running in to trouble with:
>
> def test_find_group_by_table(self):
> result = self.store.find(
> (Sum(FooValue.value2), Foo), Foo.id == FooValue.foo_id)
> result.group_by(Foo)
> foo1 = self.store.get(Foo, 10)
> foo2 = self.store.get(Foo, 20)
> self.assertEquals(list(result), [(5, foo1), (16, foo2)])
>
> This test is failing because list(result) looks like this: [(16,
> foo2), (5, foo1)]. This is the same result, but in a different order.
> I know at least at the SQL level, a query such as the above wouldn't
> be guaranteed to be in any order. But is this the case with storm?
A while back, I was working on a randomisation branch for Storm. This
added a flag that would automatically append "random()" (or whatever
the DB uses) to the end of ORDER BY clauses. The intended use was to
prevent tests from depending on undefined ordering.
I haven't yet finished the branch, since it generated invalid SQL in a
few cases but I did try turning it on for the Storm test suite itself
and ran into a few problems like the one you've found. I am inclined
to consider such tests broken rather than say that back ends that fail
on those tests are broken.
I guess it'd be worth trying out my branch again, and at least merge
fixes for the failures it discovers.
James.
More information about the storm
mailing list