lib/arel/visitors/sunstone_extensions.rb in arel-extensions-6.0.0.6 vs lib/arel/visitors/sunstone_extensions.rb in arel-extensions-6.0.0.8
- old
+ new
@@ -4,33 +4,45 @@
private
def visit_Arel_Nodes_Ascending o, collector
hash = visit(o.expr, collector)
- case o.nulls
+ value = case o.nulls
when :nulls_first
- add_to_bottom_of_hash_or_array(hash, {asc: :nulls_first})
+ {asc: :nulls_first}
when :nulls_last
- add_to_bottom_of_hash_or_array(hash, {asc: :nulls_last})
+ {asc: :nulls_last}
else
- add_to_bottom_of_hash_or_array(hash, :asc)
+ :asc
end
+ if hash.is_a?(Hash)
+ add_to_bottom_of_hash_or_array(hash, value)
+ else
+ hash = { hash => value }
+ end
+
hash
end
def visit_Arel_Nodes_Descending o, collector
hash = visit(o.expr, collector)
-
- case o.nulls
+
+ value = case o.nulls
when :nulls_first
- add_to_bottom_of_hash_or_array(hash, {desc: :nulls_first})
+ {desc: :nulls_first}
when :nulls_last
- add_to_bottom_of_hash_or_array(hash, {desc: :nulls_last})
+ {desc: :nulls_last}
else
- add_to_bottom_of_hash_or_array(hash, :desc)
+ :desc
end
-
+
+ if hash.is_a?(Hash)
+ add_to_bottom_of_hash_or_array(hash, value)
+ else
+ hash = { hash => value }
+ end
+
hash
end
def visit_Arel_Nodes_RandomOrdering o, collector
:random
\ No newline at end of file