aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra/relations/utilities/compound.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel/algebra/relations/utilities/compound.rb')
-rw-r--r--lib/arel/algebra/relations/utilities/compound.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/arel/algebra/relations/utilities/compound.rb b/lib/arel/algebra/relations/utilities/compound.rb
index 1a43c76a94..882cf8a76b 100644
--- a/lib/arel/algebra/relations/utilities/compound.rb
+++ b/lib/arel/algebra/relations/utilities/compound.rb
@@ -5,6 +5,11 @@ module Arel
:column_for, :engine, :sources, :locked, :table_alias,
:to => :relation
+ def self.requires(feature = nil)
+ @requires = feature if feature
+ @requires
+ end
+
[:attributes, :wheres, :groupings, :orders, :havings, :projections].each do |operation_name|
class_eval <<-OPERATION, __FILE__, __LINE__
def #{operation_name}
@@ -21,6 +26,18 @@ module Arel
self == other
end
+ def engine
+ requires = self.class.requires
+ engine = relation.engine
+
+ # Temporary check of whether or not the engine supports where.
+ if requires && engine.respond_to?(:supports) && !engine.supports(requires)
+ Memory::Engine.new
+ else
+ engine
+ end
+ end
+
private
def arguments_from_block(relation, &block)