aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_relation/relations/alias.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/active_relation/relations/alias.rb')
-rw-r--r--lib/active_relation/relations/alias.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/active_relation/relations/alias.rb b/lib/active_relation/relations/alias.rb
new file mode 100644
index 0000000000..97950ea5b3
--- /dev/null
+++ b/lib/active_relation/relations/alias.rb
@@ -0,0 +1,19 @@
+module ActiveRelation
+ module Relations
+ class Alias < Compound
+ attr_reader :alias
+
+ def initialize(relation, aliaz)
+ @relation, @alias = relation, aliaz
+ end
+
+ def ==(other)
+ relation == other.relation and self.alias == other.alias
+ end
+
+ def to_sql(options = {})
+ super + " AS #{@alias}"
+ end
+ end
+ end
+end \ No newline at end of file