aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/nodes
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-08-18 16:32:32 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-08-18 16:32:32 -0700
commit6b851c686faefe54efce0857f8b7b7b0c04bb673 (patch)
treec95e779ce383412519a06b4b455d31df53ea3c4d /lib/arel/nodes
parent0403efa4c6ad926a61dd0d134d63d962238e2c4f (diff)
downloadrails-6b851c686faefe54efce0857f8b7b7b0c04bb673.tar.gz
rails-6b851c686faefe54efce0857f8b7b7b0c04bb673.tar.bz2
rails-6b851c686faefe54efce0857f8b7b7b0c04bb673.zip
joins can be created
Diffstat (limited to 'lib/arel/nodes')
-rw-r--r--lib/arel/nodes/inner_join.rb13
-rw-r--r--lib/arel/nodes/on.rb11
-rw-r--r--lib/arel/nodes/table_alias.rb20
3 files changed, 44 insertions, 0 deletions
diff --git a/lib/arel/nodes/inner_join.rb b/lib/arel/nodes/inner_join.rb
new file mode 100644
index 0000000000..a39ded9f1c
--- /dev/null
+++ b/lib/arel/nodes/inner_join.rb
@@ -0,0 +1,13 @@
+module Arel
+ module Nodes
+ class InnerJoin
+ attr_accessor :left, :right, :constraint
+
+ def initialize left, right, constraint
+ @left = left
+ @right = right
+ @constraint = constraint
+ end
+ end
+ end
+end
diff --git a/lib/arel/nodes/on.rb b/lib/arel/nodes/on.rb
new file mode 100644
index 0000000000..4cc76b70db
--- /dev/null
+++ b/lib/arel/nodes/on.rb
@@ -0,0 +1,11 @@
+module Arel
+ module Nodes
+ class On
+ attr_accessor :expr
+
+ def initialize expr
+ @expr = expr
+ end
+ end
+ end
+end
diff --git a/lib/arel/nodes/table_alias.rb b/lib/arel/nodes/table_alias.rb
new file mode 100644
index 0000000000..4f1d70ee54
--- /dev/null
+++ b/lib/arel/nodes/table_alias.rb
@@ -0,0 +1,20 @@
+module Arel
+ module Nodes
+ class TableAlias
+ attr_reader :name, :relation, :columns
+
+ def initialize name, relation
+ @name = name
+ @relation = relation
+ @columns = relation.columns.map { |column|
+ column.dup.tap { |col| col.relation = self }
+ }
+ end
+
+ def [] name
+ name = name.to_s
+ columns.find { |column| column.name == name }
+ end
+ end
+ end
+end