aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel/algebra')
-rw-r--r--lib/arel/algebra/relations.rb1
-rw-r--r--lib/arel/algebra/relations/operations/from.rb6
-rw-r--r--lib/arel/algebra/relations/relation.rb3
-rw-r--r--lib/arel/algebra/relations/utilities/compound.rb2
4 files changed, 10 insertions, 2 deletions
diff --git a/lib/arel/algebra/relations.rb b/lib/arel/algebra/relations.rb
index f9fa24ba25..cee308299b 100644
--- a/lib/arel/algebra/relations.rb
+++ b/lib/arel/algebra/relations.rb
@@ -5,6 +5,7 @@ require 'arel/algebra/relations/utilities/externalization'
require 'arel/algebra/relations/row'
require 'arel/algebra/relations/writes'
require 'arel/algebra/relations/operations/alias'
+require 'arel/algebra/relations/operations/from'
require 'arel/algebra/relations/operations/group'
require 'arel/algebra/relations/operations/join'
require 'arel/algebra/relations/operations/order'
diff --git a/lib/arel/algebra/relations/operations/from.rb b/lib/arel/algebra/relations/operations/from.rb
new file mode 100644
index 0000000000..6bfd68dfc9
--- /dev/null
+++ b/lib/arel/algebra/relations/operations/from.rb
@@ -0,0 +1,6 @@
+module Arel
+ class From < Compound
+ attributes :relation, :sources
+ deriving :initialize, :==
+ end
+end
diff --git a/lib/arel/algebra/relations/relation.rb b/lib/arel/algebra/relations/relation.rb
index 5403e40fae..2ce3fdcce8 100644
--- a/lib/arel/algebra/relations/relation.rb
+++ b/lib/arel/algebra/relations/relation.rb
@@ -43,7 +43,7 @@ module Arel
join(other_relation, OuterJoin)
end
- [:where, :project, :order, :take, :skip, :group].each do |operation_name|
+ [:where, :project, :order, :take, :skip, :group, :from].each do |operation_name|
class_eval <<-OPERATION, __FILE__, __LINE__
def #{operation_name}(*arguments, &block)
arguments.all?(&:blank?) && !block_given?? self : #{operation_name.to_s.classify}.new(self, *arguments, &block)
@@ -130,6 +130,7 @@ module Arel
def joins(formatter = nil); nil end # FIXME
def taken; nil end
def skipped; nil end
+ def sources; [] end
end
include DefaultOperations
end
diff --git a/lib/arel/algebra/relations/utilities/compound.rb b/lib/arel/algebra/relations/utilities/compound.rb
index 5e775618f1..06bfce4ac0 100644
--- a/lib/arel/algebra/relations/utilities/compound.rb
+++ b/lib/arel/algebra/relations/utilities/compound.rb
@@ -2,7 +2,7 @@ module Arel
class Compound < Relation
attr_reader :relation
delegate :joins, :join?, :inserts, :taken, :skipped, :name, :externalizable?,
- :column_for, :engine,
+ :column_for, :engine, :sources,
:to => :relation
[:attributes, :wheres, :groupings, :orders].each do |operation_name|