axiom icon indicating copy to clipboard operation
axiom copied to clipboard

Relation#sort should sort on all attributes in the header

Open snusnu opened this issue 10 years ago • 4 comments

I was under the impression that the issue title describes the expected behavior. However, when i do some_base_relation_gateway.sort.drop(1).take(1), neither ORDER BY nor OFFSET/LIMIT clauses get pushed down to the underlying (postgres) adapter. The result being that the operations are ("silently") handled in memory, while performing (potentially) slow queries.

snusnu avatar Jul 14 '14 14:07 snusnu

I should maybe clarify a bit. It seems like Relation#sort actually fulfills its promise, but it does so "in memory" only. The actual operations do not get pushed down to a (sql) backend.

snusnu avatar Jul 15 '14 10:07 snusnu

@snusnu can you work out a minimal test case that demonstrates the problem? This sounds like a bug and is not at all what was intended.

dkubb avatar Jul 17 '14 05:07 dkubb

@dkubb seems like the following change to axiom-do-adapter fixes this issue:

diff --git a/lib/axiom/relation/gateway.rb b/lib/axiom/relation/gateway.rb
index 7274cc3..27d0430 100644
--- a/lib/axiom/relation/gateway.rb
+++ b/lib/axiom/relation/gateway.rb
@@ -10,7 +10,7 @@ module Axiom

       # remove methods so they can be proxied
       undef_method(*DECORATED_CLASS.public_instance_methods(false).map(&:to_s) - %w[materialize])
-      undef_method(:project, :remove, :extend, :rename, :restrict, :sort_by, :reverse, :drop, :take)
+      undef_method(:project, :remove, :extend, :rename, :restrict, :sort, :sort_by, :reverse, :drop, :take)

       # The adapter the gateway will use to fetch results
       #

snusnu avatar Jul 21 '14 15:07 snusnu

@dkubb anything i can do to further help with this one?

snusnu avatar Jul 28 '14 17:07 snusnu