diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-28 10:33:45 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-28 10:33:45 -0700 |
commit | c8830b4ac8e12504327cd231f5fdea762edeaeb8 (patch) | |
tree | 73fb51a43fdc2b8eb7c0cb3e365d3004e37d8ad4 /lib/arel | |
parent | 8a8d396cae40f272eb8c76df2e743d53fc9a8c0b (diff) | |
parent | dbdebd17f63950ec54a3cb85f8e8f8d9b0914bb4 (diff) | |
download | rails-c8830b4ac8e12504327cd231f5fdea762edeaeb8.tar.gz rails-c8830b4ac8e12504327cd231f5fdea762edeaeb8.tar.bz2 rails-c8830b4ac8e12504327cd231f5fdea762edeaeb8.zip |
Merged pull request #45 from codders/master.
Add support for specifying order direction on expressions
Diffstat (limited to 'lib/arel')
-rw-r--r-- | lib/arel/attributes/attribute.rb | 1 | ||||
-rw-r--r-- | lib/arel/expression.rb | 1 | ||||
-rw-r--r-- | lib/arel/nodes/sql_literal.rb | 1 | ||||
-rw-r--r-- | lib/arel/order_predications.rb | 13 | ||||
-rw-r--r-- | lib/arel/predications.rb | 9 |
5 files changed, 17 insertions, 8 deletions
diff --git a/lib/arel/attributes/attribute.rb b/lib/arel/attributes/attribute.rb index 240f224d8c..b9fd8da67e 100644 --- a/lib/arel/attributes/attribute.rb +++ b/lib/arel/attributes/attribute.rb @@ -3,6 +3,7 @@ module Arel class Attribute < Struct.new :relation, :name include Arel::Expressions include Arel::Predications + include Arel::OrderPredications include Arel::Math ### diff --git a/lib/arel/expression.rb b/lib/arel/expression.rb index eb2c21bfd3..3884d6ede6 100644 --- a/lib/arel/expression.rb +++ b/lib/arel/expression.rb @@ -1,4 +1,5 @@ module Arel module Expression + include Arel::OrderPredications end end diff --git a/lib/arel/nodes/sql_literal.rb b/lib/arel/nodes/sql_literal.rb index c76a16daf1..ad0bb00484 100644 --- a/lib/arel/nodes/sql_literal.rb +++ b/lib/arel/nodes/sql_literal.rb @@ -3,6 +3,7 @@ module Arel class SqlLiteral < String include Arel::Expressions include Arel::Predications + include Arel::OrderPredications end end end diff --git a/lib/arel/order_predications.rb b/lib/arel/order_predications.rb new file mode 100644 index 0000000000..af163c9454 --- /dev/null +++ b/lib/arel/order_predications.rb @@ -0,0 +1,13 @@ +module Arel + module OrderPredications + + def asc + Nodes::Ordering.new self, :asc + end + + def desc + Nodes::Ordering.new self, :desc + end + + end +end diff --git a/lib/arel/predications.rb b/lib/arel/predications.rb index 7e2425e45f..08cbf16d9d 100644 --- a/lib/arel/predications.rb +++ b/lib/arel/predications.rb @@ -1,5 +1,6 @@ module Arel module Predications + def as other Nodes::As.new self, Nodes::SqlLiteral.new(other) end @@ -152,14 +153,6 @@ module Arel grouping_all :lteq, others end - def asc - Nodes::Ordering.new self, :asc - end - - def desc - Nodes::Ordering.new self, :desc - end - private def grouping_any method_id, others |