Hello community, here is the log from the commit of package rubygem-arel for openSUSE:Factory checked in at 2016-08-26 23:17:01 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-arel (Old) and /work/SRC/openSUSE:Factory/.rubygem-arel.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-arel" Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-arel/rubygem-arel.changes 2016-04-28 16:52:58.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-arel.new/rubygem-arel.changes 2016-08-26 23:17:03.000000000 +0200 @@ -1,0 +2,26 @@ +Thu Jul 28 04:28:39 UTC 2016 - [email protected] + +- updated to version 7.1.1 + see installed History.txt + + === 7.1.1 / 2016-07-27 + + * Bug Fixes + + * Fix warning in `Casted#hash` + +------------------------------------------------------------------- +Wed Jul 20 04:28:32 UTC 2016 - [email protected] + +- updated to version 7.1.0 + see installed History.txt + + === 7.1.0 / 2016-07-19 + + * Enhancements + + * Support Ruby 2.4 unified Integer class + * Implement `CASE` conditional expression + * Support for Bitwise Operations as `InfixOperations` + +------------------------------------------------------------------- Old: ---- arel-7.0.0.gem New: ---- arel-7.1.1.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-arel.spec ++++++ --- /var/tmp/diff_new_pack.LSRw6S/_old 2016-08-26 23:17:04.000000000 +0200 +++ /var/tmp/diff_new_pack.LSRw6S/_new 2016-08-26 23:17:04.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package rubygem-arel # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,7 +24,7 @@ # Name: rubygem-arel -Version: 7.0.0 +Version: 7.1.1 Release: 0 %define mod_name arel %define mod_full_name %{mod_name}-%{version} @@ -56,7 +56,7 @@ %install %gem_install \ - --doc-files="History.txt MIT-LICENSE.txt README.markdown" \ + --doc-files="History.txt MIT-LICENSE.txt README.md" \ -f %gem_packages ++++++ arel-7.0.0.gem -> arel-7.1.1.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/History.txt new/History.txt --- old/History.txt 2015-12-17 21:03:56.000000000 +0100 +++ new/History.txt 2016-07-28 01:17:50.000000000 +0200 @@ -1,3 +1,17 @@ +=== 7.1.1 / 2016-07-27 + +* Bug Fixes + + * Fix warning in `Casted#hash` + +=== 7.1.0 / 2016-07-19 + +* Enhancements + + * Support Ruby 2.4 unified Integer class + * Implement `CASE` conditional expression + * Support for Bitwise Operations as `InfixOperations` + === 7.0.0 / 2015-12-17 * Enhancements diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/MIT-LICENSE.txt new/MIT-LICENSE.txt --- old/MIT-LICENSE.txt 2015-12-17 21:03:56.000000000 +0100 +++ new/MIT-LICENSE.txt 2016-07-28 01:17:50.000000000 +0200 @@ -1,4 +1,4 @@ -Copyright (c) 2007-2015 Nick Kallen, Bryan Helmkamp, Emilio Tagua, Aaron Patterson +Copyright (c) 2007-2016 Nick Kallen, Bryan Helmkamp, Emilio Tagua, Aaron Patterson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.markdown new/README.markdown --- old/README.markdown 2015-12-17 21:03:56.000000000 +0100 +++ new/README.markdown 1970-01-01 01:00:00.000000000 +0100 @@ -1,233 +0,0 @@ -# Arel - -* http://github.com/rails/arel - -## DESCRIPTION - -Arel Really Exasperates Logicians - -Arel is a SQL AST manager for Ruby. It - -1. Simplifies the generation of complex SQL queries -2. Adapts to various RDBMSes - -It is intended to be a framework framework; that is, you can build your own ORM -with it, focusing on innovative object and collection modeling as opposed to -database compatibility and query generation. - -## Status - -For the moment, Arel uses Active Record's connection adapters to connect to the various engines, connection pooling, perform quoting, and do type conversion. - -## A Gentle Introduction - -Generating a query with Arel is simple. For example, in order to produce - -```sql -SELECT * FROM users -``` - -you construct a table relation and convert it to sql: - -```ruby -users = Arel::Table.new(:users) -query = users.project(Arel.sql('*')) -query.to_sql -``` - -### More Sophisticated Queries - -Here is a whirlwind tour through the most common SQL operators. These will probably cover 80% of all interaction with the database. - -First is the 'restriction' operator, `where`: - -```ruby -users.where(users[:name].eq('amy')) -# => SELECT * FROM users WHERE users.name = 'amy' -``` - -What would, in SQL, be part of the `SELECT` clause is called in Arel a `projection`: - -```ruby -users.project(users[:id]) -# => SELECT users.id FROM users -``` - -Comparison operators `=`, `!=`, `<`, `>`, `<=`, `>=`, `IN`: - -```ruby -users.where(users[:age].eq(10)).project(Arel.sql('*')) # => SELECT * FROM "users" WHERE "users"."age" = 10 -users.where(users[:age].not_eq(10)).project(Arel.sql('*')) # => SELECT * FROM "users" WHERE "users"."age" != 10 -users.where(users[:age].lt(10)).project(Arel.sql('*')) # => SELECT * FROM "users" WHERE "users"."age" < 10 -users.where(users[:age].gt(10)).project(Arel.sql('*')) # => SELECT * FROM "users" WHERE "users"."age" > 10 -users.where(users[:age].lteq(10)).project(Arel.sql('*')) # => SELECT * FROM "users" WHERE "users"."age" <= 10 -users.where(users[:age].gteq(10)).project(Arel.sql('*')) # => SELECT * FROM "users" WHERE "users"."age" >= 10 -users.where(users[:age].in([20, 16, 17])).project(Arel.sql('*')) # => SELECT * FROM "users" WHERE "users"."age" IN (20, 16, 17) -``` - -Joins resemble SQL strongly: - -```ruby -users.join(photos).on(users[:id].eq(photos[:user_id])) -# => SELECT * FROM users INNER JOIN photos ON users.id = photos.user_id -``` - -Left Joins - -```ruby -users.join(photos, Arel::Nodes::OuterJoin).on(users[:id].eq(photos[:user_id])) -# => SELECT FROM users LEFT OUTER JOIN photos ON users.id = photos.user_id -``` - -What are called `LIMIT` and `OFFSET` in SQL are called `take` and `skip` in Arel: - -```ruby -users.take(5) # => SELECT * FROM users LIMIT 5 -users.skip(4) # => SELECT * FROM users OFFSET 4 -``` - -`GROUP BY` is called `group`: - -```ruby -users.project(users[:name]).group(users[:name]) -# => SELECT users.name FROM users GROUP BY users.name -``` - -The best property of arel is its "composability", or closure under all operations. For example, to restrict AND project, just "chain" the method invocations: - -```ruby -users \ - .where(users[:name].eq('amy')) \ - .project(users[:id]) \ -# => SELECT users.id FROM users WHERE users.name = 'amy' -``` - -All operators are chainable in this way, and they are chainable any number of times, in any order. - -```ruby -users.where(users[:name].eq('bob')).where(users[:age].lt(25)) -``` - -The `OR` operator works like this: - -```ruby -users.where(users[:name].eq('bob').or(users[:age].lt(25))) -``` - -The `AND` operator behaves similarly. - -Aggregate functions `AVG`, `SUM`, `COUNT`, `MIN`, `MAX`, `HAVING`: - -```ruby -photos.group(photos[:user_id]).having(photos[:id].count.gt(5)) # => SELECT FROM photos GROUP BY photos.user_id HAVING COUNT(photos.id) > 5 -users.project(users[:age].sum) # => SELECT SUM(users.age) FROM users -users.project(users[:age].average) # => SELECT AVG(users.age) FROM users -users.project(users[:age].maximum) # => SELECT MAX(users.age) FROM users -users.project(users[:age].minimum) # => SELECT MIN(users.age) FROM users -users.project(users[:age].count) # => SELECT COUNT(users.age) FROM users -``` - -Aliasing Aggregate Functions: - -```ruby -users.project(users[:age].average.as("mean_age")) # => SELECT AVG(users.age) AS mean_age FROM users -``` - -### The Crazy Features - -The examples above are fairly simple and other libraries match or come close to matching the expressiveness of Arel (e.g., `Sequel` in Ruby). - -#### Inline math operations - -Suppose we have a table `products` with prices in different currencies. And we have a table `currency_rates`, of constantly changing currency rates. In Arel: - -```ruby -products = Arel::Table.new(:products) -# Attributes: [:id, :name, :price, :currency_id] - -currency_rates = Arel::Table.new(:currency_rates) -# Attributes: [:from_id, :to_id, :date, :rate] -``` - -Now, to order products by price in user preferred currency simply call: - -```ruby -products. - join(:currency_rates).on(products[:currency_id].eq(currency_rates[:from_id])). - where(currency_rates[:to_id].eq(user_preferred_currency), currency_rates[:date].eq(Date.today)). - order(products[:price] * currency_rates[:rate]) -``` - -#### Complex Joins - -Where Arel really shines is in its ability to handle complex joins and aggregations. As a first example, let's consider an "adjacency list", a tree represented in a table. Suppose we have a table `comments`, representing a threaded discussion: - -```ruby -comments = Arel::Table.new(:comments) -``` - -And this table has the following attributes: - -```ruby -# [:id, :body, :parent_id] -``` - -The `parent_id` column is a foreign key from the `comments` table to itself. -Joining a table to itself requires aliasing in SQL. This aliasing can be handled from Arel as below: - -```ruby -replies = comments.alias -comments_with_replies = \ - comments.join(replies).on(replies[:parent_id].eq(comments[:id])).where(comments[:id].eq(1)) -# => SELECT * FROM comments INNER JOIN comments AS comments_2 WHERE comments_2.parent_id = comments.id AND comments.id = 1 -``` - -This will return the reply for the first comment. - -[Common Table Expressions(CTE)](https://en.wikipedia.org/wiki/Common_table_expressions#Common_table_expression) support via: - -Create a `CTE` - -```ruby -cte_table = Arel::Table.new(:cte_table) -composed_cte = Arel::Nodes::As.new(cte_table, photos.where(photos[:created_at].gt(Date.current))) -``` - -Use the created `CTE`: - -```ruby -users. - join(cte_table).on(users[:id].eq(cte_table[:user_id])). - project(users[:id], cte_table[:click].sum). - with(composed_cte) - -# => WITH cte_table AS (SELECT FROM photos WHERE photos.created_at > '2014-05-02') SELECT users.id, SUM(cte_table.click) FROM users INNER JOIN cte_table ON users.id = cte_table.user_id -``` - -When your query is too complex for `Arel`, you can use `Arel::SqlLiteral`: - -```ruby -photo_clicks = Arel::Nodes::SqlLiteral.new(<<-SQL - CASE WHEN condition1 THEN calculation1 - WHEN condition2 THEN calculation2 - WHEN condition3 THEN calculation3 - ELSE default_calculation END -SQL -) -photos.project(photo_clicks.as("photo_clicks")) -# => SELECT CASE WHEN condition1 THEN calculation1 - WHEN condition2 THEN calculation2 - WHEN condition3 THEN calculation3 - ELSE default_calculation END - FROM "photos" -``` - -## Contributing to Arel - -Arel is work of many contributors. You're encouraged to submit pull requests, propose -features and discuss issues. - -See [CONTRIBUTING](CONTRIBUTING.md). - -## License -Arel is released under the [MIT License](http://www.opensource.org/licenses/MIT). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/README.md 2016-07-28 01:17:50.000000000 +0200 @@ -0,0 +1,284 @@ +# Arel + +* http://github.com/rails/arel + +## DESCRIPTION + +Arel Really Exasperates Logicians + +Arel is a SQL AST manager for Ruby. It + +1. simplifies the generation of complex SQL queries, and +2. adapts to various RDBMSes. + +It is intended to be a framework framework; that is, you can build your own ORM +with it, focusing on innovative object and collection modeling as opposed to +database compatibility and query generation. + +## Status + +For the moment, Arel uses Active Record's connection adapters to connect to the various engines and perform connection pooling, quoting, and type conversion. + +## A Gentle Introduction + +Generating a query with Arel is simple. For example, in order to produce + +```sql +SELECT * FROM users +``` + +you construct a table relation and convert it to SQL: + +```ruby +users = Arel::Table.new(:users) +query = users.project(Arel.sql('*')) +query.to_sql +``` + +### More Sophisticated Queries + +Here is a whirlwind tour through the most common SQL operators. These will probably cover 80% of all interaction with the database. + +First is the 'restriction' operator, `where`: + +```ruby +users.where(users[:name].eq('amy')) +# => SELECT * FROM users WHERE users.name = 'amy' +``` + +What would, in SQL, be part of the `SELECT` clause is called in Arel a `projection`: + +```ruby +users.project(users[:id]) +# => SELECT users.id FROM users +``` + +Comparison operators `=`, `!=`, `<`, `>`, `<=`, `>=`, `IN`: + +```ruby +users.where(users[:age].eq(10)).project(Arel.sql('*')) +# => SELECT * FROM "users" WHERE "users"."age" = 10 + +users.where(users[:age].not_eq(10)).project(Arel.sql('*')) +# => SELECT * FROM "users" WHERE "users"."age" != 10 + +users.where(users[:age].lt(10)).project(Arel.sql('*')) +# => SELECT * FROM "users" WHERE "users"."age" < 10 + +users.where(users[:age].gt(10)).project(Arel.sql('*')) +# => SELECT * FROM "users" WHERE "users"."age" > 10 + +users.where(users[:age].lteq(10)).project(Arel.sql('*')) +# => SELECT * FROM "users" WHERE "users"."age" <= 10 + +users.where(users[:age].gteq(10)).project(Arel.sql('*')) +# => SELECT * FROM "users" WHERE "users"."age" >= 10 + +users.where(users[:age].in([20, 16, 17])).project(Arel.sql('*')) +# => SELECT * FROM "users" WHERE "users"."age" IN (20, 16, 17) +``` + +Bitwise operators `&`, `|`, `^`, `<<`, `>>`: + +```ruby +users.where((users[:bitmap] & 16).gt(0)).project(Arel.sql('*')) +# => SELECT * FROM "users" WHERE ("users"."bitmap" & 16) > 0 + +users.where((users[:bitmap] | 16).gt(0)).project(Arel.sql('*')) +# => SELECT * FROM "users" WHERE ("users"."bitmap" | 16) > 0 + +users.where((users[:bitmap] ^ 16).gt(0)).project(Arel.sql('*')) +# => SELECT * FROM "users" WHERE ("users"."bitmap" ^ 16) > 0 + +users.where((users[:bitmap] << 1).gt(0)).project(Arel.sql('*')) +# => SELECT * FROM "users" WHERE ("users"."bitmap" << 1) > 0 + +users.where((users[:bitmap] >> 1).gt(0)).project(Arel.sql('*')) +# => SELECT * FROM "users" WHERE ("users"."bitmap" >> 1) > 0 + +users.where((~ users[:bitmap]).gt(0)).project(Arel.sql('*')) +# => SELECT FROM "users" WHERE ~ "users"."bitmap" > 0 +``` + +Joins resemble SQL strongly: + +```ruby +users.join(photos).on(users[:id].eq(photos[:user_id])) +# => SELECT * FROM users INNER JOIN photos ON users.id = photos.user_id +``` + +Left joins: + +```ruby +users.join(photos, Arel::Nodes::OuterJoin).on(users[:id].eq(photos[:user_id])) +# => SELECT FROM users LEFT OUTER JOIN photos ON users.id = photos.user_id +``` + +What are called `LIMIT` and `OFFSET` in SQL are called `take` and `skip` in Arel: + +```ruby +users.take(5) # => SELECT * FROM users LIMIT 5 +users.skip(4) # => SELECT * FROM users OFFSET 4 +``` + +`GROUP BY` is called `group`: + +```ruby +users.project(users[:name]).group(users[:name]) +# => SELECT users.name FROM users GROUP BY users.name +``` + +The best property of Arel is its "composability," or closure under all operations. For example, to restrict AND project, just "chain" the method invocations: + +```ruby +users \ + .where(users[:name].eq('amy')) \ + .project(users[:id]) \ +# => SELECT users.id FROM users WHERE users.name = 'amy' +``` + +All operators are chainable in this way, and they are chainable any number of times, in any order. + +```ruby +users.where(users[:name].eq('bob')).where(users[:age].lt(25)) +``` + +The `OR` operator works like this: + +```ruby +users.where(users[:name].eq('bob').or(users[:age].lt(25))) +``` + +The `AND` operator behaves similarly. + +Aggregate functions `AVG`, `SUM`, `COUNT`, `MIN`, `MAX`, `HAVING`: + +```ruby +photos.group(photos[:user_id]).having(photos[:id].count.gt(5)) +# => SELECT FROM photos GROUP BY photos.user_id HAVING COUNT(photos.id) > 5 + +users.project(users[:age].sum) +# => SELECT SUM(users.age) FROM users + +users.project(users[:age].average) +# => SELECT AVG(users.age) FROM users + +users.project(users[:age].maximum) +# => SELECT MAX(users.age) FROM users + +users.project(users[:age].minimum) +# => SELECT MIN(users.age) FROM users + +users.project(users[:age].count) +# => SELECT COUNT(users.age) FROM users +``` + +Aliasing Aggregate Functions: + +```ruby +users.project(users[:age].average.as("mean_age")) +# => SELECT AVG(users.age) AS mean_age FROM users +``` + +### The Crazy Features + +The examples above are fairly simple and other libraries match or come close to matching the expressiveness of Arel (e.g. `Sequel` in Ruby). + +#### Inline math operations + +Suppose we have a table `products` with prices in different currencies. And we have a table `currency_rates`, of constantly changing currency rates. In Arel: + +```ruby +products = Arel::Table.new(:products) +# Attributes: [:id, :name, :price, :currency_id] + +currency_rates = Arel::Table.new(:currency_rates) +# Attributes: [:from_id, :to_id, :date, :rate] +``` + +Now, to order products by price in user preferred currency simply call: + +```ruby +products. + join(:currency_rates).on(products[:currency_id].eq(currency_rates[:from_id])). + where(currency_rates[:to_id].eq(user_preferred_currency), currency_rates[:date].eq(Date.today)). + order(products[:price] * currency_rates[:rate]) +``` + +#### Complex Joins + +Where Arel really shines is in its ability to handle complex joins and aggregations. As a first example, let's consider an "adjacency list", a tree represented in a table. Suppose we have a table `comments`, representing a threaded discussion: + +```ruby +comments = Arel::Table.new(:comments) +``` + +And this table has the following attributes: + +```ruby +# [:id, :body, :parent_id] +``` + +The `parent_id` column is a foreign key from the `comments` table to itself. +Joining a table to itself requires aliasing in SQL. This aliasing can be handled from Arel as below: + +```ruby +replies = comments.alias +comments_with_replies = \ + comments.join(replies).on(replies[:parent_id].eq(comments[:id])).where(comments[:id].eq(1)) +# => SELECT * FROM comments INNER JOIN comments AS comments_2 +# WHERE comments_2.parent_id = comments.id AND comments.id = 1 +``` + +This will return the reply for the first comment. + +[Common Table Expressions (CTE)](https://en.wikipedia.org/wiki/Common_table_expressions#Common_table_expression) support via: + +Create a `CTE` + +```ruby +cte_table = Arel::Table.new(:cte_table) +composed_cte = Arel::Nodes::As.new(cte_table, photos.where(photos[:created_at].gt(Date.current))) +``` + +Use the created `CTE`: + +```ruby +users. + join(cte_table).on(users[:id].eq(cte_table[:user_id])). + project(users[:id], cte_table[:click].sum). + with(composed_cte) + +# => WITH cte_table AS (SELECT FROM photos WHERE photos.created_at > '2014-05-02') +# SELECT users.id, SUM(cte_table.click) +# FROM users INNER JOIN cte_table ON users.id = cte_table.user_id +``` + +When your query is too complex for `Arel`, you can use `Arel::SqlLiteral`: + +```ruby +photo_clicks = Arel::Nodes::SqlLiteral.new(<<-SQL + CASE WHEN condition1 THEN calculation1 + WHEN condition2 THEN calculation2 + WHEN condition3 THEN calculation3 + ELSE default_calculation END +SQL +) + +photos.project(photo_clicks.as("photo_clicks")) +# => SELECT CASE WHEN condition1 THEN calculation1 +# WHEN condition2 THEN calculation2 +# WHEN condition3 THEN calculation3 +# ELSE default_calculation END +# FROM "photos" +``` + +## Contributing to Arel + +Arel is the work of many contributors. You're encouraged to submit pull requests, propose +features and discuss issues. + +See [CONTRIBUTING](CONTRIBUTING.md). + +## License +Arel is released under the [MIT License](http://www.opensource.org/licenses/MIT). Files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/arel/math.rb new/lib/arel/math.rb --- old/lib/arel/math.rb 2015-12-17 21:03:57.000000000 +0100 +++ new/lib/arel/math.rb 2016-07-28 01:17:50.000000000 +0200 @@ -15,5 +15,29 @@ def /(other) Arel::Nodes::Division.new(self, other) end + + def &(other) + Arel::Nodes::Grouping.new(Arel::Nodes::BitwiseAnd.new(self, other)) + end + + def |(other) + Arel::Nodes::Grouping.new(Arel::Nodes::BitwiseOr.new(self, other)) + end + + def ^(other) + Arel::Nodes::Grouping.new(Arel::Nodes::BitwiseXor.new(self, other)) + end + + def <<(other) + Arel::Nodes::Grouping.new(Arel::Nodes::BitwiseShiftLeft.new(self, other)) + end + + def >>(other) + Arel::Nodes::Grouping.new(Arel::Nodes::BitwiseShiftRight.new(self, other)) + end + + def ~@ + Arel::Nodes::BitwiseNot.new(self) + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/arel/nodes/case.rb new/lib/arel/nodes/case.rb --- old/lib/arel/nodes/case.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/arel/nodes/case.rb 2016-07-28 01:17:50.000000000 +0200 @@ -0,0 +1,57 @@ +module Arel + module Nodes + class Case < Arel::Nodes::Node + include Arel::OrderPredications + include Arel::Predications + include Arel::AliasPredication + + attr_accessor :case, :conditions, :default + + def initialize expression = nil, default = nil + @case = expression + @conditions = [] + @default = default + end + + def when condition, expression = nil + @conditions << When.new(Nodes.build_quoted(condition), expression) + self + end + + def then expression + @conditions.last.right = Nodes.build_quoted(expression) + self + end + + def else expression + @default = Else.new Nodes.build_quoted(expression) + self + end + + def initialize_copy other + super + @case = @case.clone if @case + @conditions = @conditions.map { |x| x.clone } + @default = @default.clone if @default + end + + def hash + [@case, @conditions, @default].hash + end + + def eql? other + self.class == other.class && + self.case == other.case && + self.conditions == other.conditions && + self.default == other.default + end + alias :== :eql? + end + + class When < Binary # :nodoc: + end + + class Else < Unary # :nodoc: + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/arel/nodes/casted.rb new/lib/arel/nodes/casted.rb --- old/lib/arel/nodes/casted.rb 2015-12-17 21:03:57.000000000 +0100 +++ new/lib/arel/nodes/casted.rb 2016-07-28 01:17:50.000000000 +0200 @@ -10,6 +10,10 @@ def nil?; @val.nil?; end + def hash + [self.class, val, attribute].hash + end + def eql? other self.class == other.class && self.val == other.val && diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/arel/nodes/infix_operation.rb new/lib/arel/nodes/infix_operation.rb --- old/lib/arel/nodes/infix_operation.rb 2015-12-17 21:03:57.000000000 +0100 +++ new/lib/arel/nodes/infix_operation.rb 2016-07-28 01:17:50.000000000 +0200 @@ -40,5 +40,40 @@ end end + class Concat < InfixOperation + def initialize left, right + super('||', left, right) + end + end + + class BitwiseAnd < InfixOperation + def initialize left, right + super(:&, left, right) + end + end + + class BitwiseOr < InfixOperation + def initialize left, right + super(:|, left, right) + end + end + + class BitwiseXor < InfixOperation + def initialize left, right + super(:^, left, right) + end + end + + class BitwiseShiftLeft < InfixOperation + def initialize left, right + super(:<<, left, right) + end + end + + class BitwiseShiftRight < InfixOperation + def initialize left, right + super(:>>, left, right) + end + end end -end \ No newline at end of file +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/arel/nodes/unary.rb new/lib/arel/nodes/unary.rb --- old/lib/arel/nodes/unary.rb 2015-12-17 21:03:57.000000000 +0100 +++ new/lib/arel/nodes/unary.rb 2016-07-28 01:17:50.000000000 +0200 @@ -22,15 +22,19 @@ %w{ Bin + Cube + DistinctOn Group + GroupingElement + GroupingSet Limit + Lock Not Offset On Ordering + RollUp Top - Lock - DistinctOn }.each do |name| const_set(name, Class.new(Unary)) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/arel/nodes/unary_operation.rb new/lib/arel/nodes/unary_operation.rb --- old/lib/arel/nodes/unary_operation.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/arel/nodes/unary_operation.rb 2016-07-28 01:17:50.000000000 +0200 @@ -0,0 +1,25 @@ +module Arel + module Nodes + + class UnaryOperation < Unary + include Arel::Expressions + include Arel::Predications + include Arel::OrderPredications + include Arel::AliasPredication + include Arel::Math + + attr_reader :operator + + def initialize operator, operand + super(operand) + @operator = operator + end + end + + class BitwiseNot < UnaryOperation + def initialize operand + super(:~, operand) + end + end + end +end \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/arel/nodes.rb new/lib/arel/nodes.rb --- old/lib/arel/nodes.rb 2015-12-17 21:03:57.000000000 +0100 +++ new/lib/arel/nodes.rb 2016-07-28 01:17:50.000000000 +0200 @@ -28,6 +28,7 @@ require 'arel/nodes/delete_statement' require 'arel/nodes/table_alias' require 'arel/nodes/infix_operation' +require 'arel/nodes/unary_operation' require 'arel/nodes/over' require 'arel/nodes/matches' require 'arel/nodes/regexp' @@ -47,6 +48,9 @@ # windows require 'arel/nodes/window' +# conditional expressions +require 'arel/nodes/case' + # joins require 'arel/nodes/full_outer_join' require 'arel/nodes/inner_join' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/arel/predications.rb new/lib/arel/predications.rb --- old/lib/arel/predications.rb 2015-12-17 21:03:57.000000000 +0100 +++ new/lib/arel/predications.rb 2016-07-28 01:17:50.000000000 +0200 @@ -198,6 +198,14 @@ grouping_all :lteq, others end + def when right + Nodes::Case.new(self).when quoted_node(right) + end + + def concat other + Nodes::Concat.new self, other + end + private def grouping_any method_id, others, *extras diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/arel/visitors/depth_first.rb new/lib/arel/visitors/depth_first.rb --- old/lib/arel/visitors/depth_first.rb 2015-12-17 21:03:57.000000000 +0100 +++ new/lib/arel/visitors/depth_first.rb 2016-07-28 01:17:50.000000000 +0200 @@ -16,7 +16,12 @@ def unary o visit o.expr end + alias :visit_Arel_Nodes_Else :unary alias :visit_Arel_Nodes_Group :unary + alias :visit_Arel_Nodes_Cube :unary + alias :visit_Arel_Nodes_RollUp :unary + alias :visit_Arel_Nodes_GroupingSet :unary + alias :visit_Arel_Nodes_GroupingElement :unary alias :visit_Arel_Nodes_Grouping :unary alias :visit_Arel_Nodes_Having :unary alias :visit_Arel_Nodes_Limit :unary @@ -53,6 +58,12 @@ visit o.distinct end + def visit_Arel_Nodes_Case o + visit o.case + visit o.conditions + visit o.default + end + def nary o o.children.each { |child| visit child} end @@ -65,6 +76,7 @@ alias :visit_Arel_Nodes_As :binary alias :visit_Arel_Nodes_Assignment :binary alias :visit_Arel_Nodes_Between :binary + alias :visit_Arel_Nodes_Concat :binary alias :visit_Arel_Nodes_DeleteStatement :binary alias :visit_Arel_Nodes_DoesNotMatch :binary alias :visit_Arel_Nodes_Equality :binary @@ -86,8 +98,9 @@ alias :visit_Arel_Nodes_Regexp :binary alias :visit_Arel_Nodes_RightOuterJoin :binary alias :visit_Arel_Nodes_TableAlias :binary - alias :visit_Arel_Nodes_Values :binary alias :visit_Arel_Nodes_Union :binary + alias :visit_Arel_Nodes_Values :binary + alias :visit_Arel_Nodes_When :binary def visit_Arel_Nodes_StringJoin o visit o.left @@ -128,6 +141,7 @@ alias :visit_FalseClass :terminal alias :visit_Fixnum :terminal alias :visit_Float :terminal + alias :visit_Integer :terminal alias :visit_NilClass :terminal alias :visit_String :terminal alias :visit_Symbol :terminal diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/arel/visitors/dot.rb new/lib/arel/visitors/dot.rb --- old/lib/arel/visitors/dot.rb 2015-12-17 21:03:57.000000000 +0100 +++ new/lib/arel/visitors/dot.rb 2016-07-28 01:17:50.000000000 +0200 @@ -69,6 +69,10 @@ visit_edge o, "expr" end alias :visit_Arel_Nodes_Group :unary + alias :visit_Arel_Nodes_Cube :unary + alias :visit_Arel_Nodes_RollUp :unary + alias :visit_Arel_Nodes_GroupingSet :unary + alias :visit_Arel_Nodes_GroupingElement :unary alias :visit_Arel_Nodes_Grouping :unary alias :visit_Arel_Nodes_Having :unary alias :visit_Arel_Nodes_Limit :unary @@ -176,6 +180,7 @@ alias :visit_Arel_Nodes_As :binary alias :visit_Arel_Nodes_Assignment :binary alias :visit_Arel_Nodes_Between :binary + alias :visit_Arel_Nodes_Concat :binary alias :visit_Arel_Nodes_DoesNotMatch :binary alias :visit_Arel_Nodes_Equality :binary alias :visit_Arel_Nodes_GreaterThan :binary @@ -200,6 +205,7 @@ alias :visit_TrueClass :visit_String alias :visit_FalseClass :visit_String alias :visit_Arel_Nodes_BindParam :visit_String + alias :visit_Integer :visit_String alias :visit_Fixnum :visit_String alias :visit_BigDecimal :visit_String alias :visit_Float :visit_String diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/arel/visitors/mysql.rb new/lib/arel/visitors/mysql.rb --- old/lib/arel/visitors/mysql.rb 2015-12-17 21:03:57.000000000 +0100 +++ new/lib/arel/visitors/mysql.rb 2016-07-28 01:17:50.000000000 +0200 @@ -72,6 +72,14 @@ maybe_visit o.limit, collector end + def visit_Arel_Nodes_Concat o, collector + collector << " CONCAT(" + visit o.left, collector + collector << ", " + visit o.right, collector + collector << ") " + collector + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/arel/visitors/oracle12.rb new/lib/arel/visitors/oracle12.rb --- old/lib/arel/visitors/oracle12.rb 2015-12-17 21:03:57.000000000 +0100 +++ new/lib/arel/visitors/oracle12.rb 2016-07-28 01:17:50.000000000 +0200 @@ -6,10 +6,12 @@ def visit_Arel_Nodes_SelectStatement o, collector # Oracle does not allow LIMIT clause with select for update if o.limit && o.lock - o = o.dup - o.limit = [] + raise ArgumentError, <<-MSG + 'Combination of limit and lock is not supported. + because generated SQL statements + `SELECT FOR UPDATE and FETCH FIRST n ROWS` generates ORA-02014.` + MSG end - super end @@ -48,6 +50,10 @@ super end + + def visit_Arel_Nodes_BindParam o, collector + collector.add_bind(o) { |i| ":a#{i}" } + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/arel/visitors/postgresql.rb new/lib/arel/visitors/postgresql.rb --- old/lib/arel/visitors/postgresql.rb 2015-12-17 21:03:57.000000000 +0100 +++ new/lib/arel/visitors/postgresql.rb 2016-07-28 01:17:50.000000000 +0200 @@ -1,6 +1,10 @@ module Arel module Visitors class PostgreSQL < Arel::Visitors::ToSql + CUBE = 'CUBE' + ROLLUP = 'ROLLUP' + GROUPING_SET = 'GROUPING SET' + private def visit_Arel_Nodes_Matches o, collector @@ -43,6 +47,38 @@ def visit_Arel_Nodes_BindParam o, collector collector.add_bind(o) { |i| "$#{i}" } end + + def visit_Arel_Nodes_GroupingElement o, collector + collector << "( " + visit(o.expr, collector) << " )" + end + + def visit_Arel_Nodes_Cube o, collector + collector << CUBE + grouping_array_or_grouping_element o, collector + end + + def visit_Arel_Nodes_RollUp o, collector + collector << ROLLUP + grouping_array_or_grouping_element o, collector + end + + def visit_Arel_Nodes_GroupingSet o, collector + collector << GROUPING_SET + grouping_array_or_grouping_element o, collector + end + + # Utilized by GroupingSet, Cube & RollUp visitors to + # handle grouping aggregation semantics + def grouping_array_or_grouping_element o, collector + if o.expr.is_a? Array + collector << "( " + visit o.expr, collector + collector << " )" + else + visit o.expr, collector + end + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/arel/visitors/sqlite.rb new/lib/arel/visitors/sqlite.rb --- old/lib/arel/visitors/sqlite.rb 2015-12-17 21:03:57.000000000 +0100 +++ new/lib/arel/visitors/sqlite.rb 2016-07-28 01:17:50.000000000 +0200 @@ -12,6 +12,15 @@ o.limit = Arel::Nodes::Limit.new(-1) if o.offset && !o.limit super end + + def visit_Arel_Nodes_True o, collector + collector << "1" + end + + def visit_Arel_Nodes_False o, collector + collector << "0" + end + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/arel/visitors/to_sql.rb new/lib/arel/visitors/to_sql.rb --- old/lib/arel/visitors/to_sql.rb 2015-12-17 21:03:57.000000000 +0100 +++ new/lib/arel/visitors/to_sql.rb 2016-07-28 01:17:50.000000000 +0200 @@ -199,7 +199,7 @@ collector << quote(value, attr && column_for(attr)).to_s end unless i == len - collector << ', ' + collector << COMMA end } @@ -243,53 +243,33 @@ collector = maybe_visit o.set_quantifier, collector - unless o.projections.empty? - collector << SPACE - len = o.projections.length - 1 - o.projections.each_with_index do |x, i| - collector = visit(x, collector) - collector << COMMA unless len == i - end - end + collect_nodes_for o.projections, collector, SPACE if o.source && !o.source.empty? collector << " FROM " collector = visit o.source, collector end - unless o.wheres.empty? - collector << WHERE - len = o.wheres.length - 1 - o.wheres.each_with_index do |x, i| - collector = visit(x, collector) - collector << AND unless len == i - end - end - - unless o.groups.empty? - collector << GROUP_BY - len = o.groups.length - 1 - o.groups.each_with_index do |x, i| - collector = visit(x, collector) - collector << COMMA unless len == i - end - end - + collect_nodes_for o.wheres, collector, WHERE, AND + collect_nodes_for o.groups, collector, GROUP_BY unless o.havings.empty? collector << " HAVING " inject_join o.havings, collector, AND end + collect_nodes_for o.windows, collector, WINDOW - unless o.windows.empty? - collector << WINDOW - len = o.windows.length - 1 - o.windows.each_with_index do |x, i| + collector + end + + def collect_nodes_for nodes, collector, spacer, connector = COMMA + unless nodes.empty? + collector << spacer + len = nodes.length - 1 + nodes.each_with_index do |x, i| collector = visit(x, collector) - collector << COMMA unless len == i + collector << connector unless len == i end end - - collector end def visit_Arel_Nodes_Bin o, collector @@ -349,13 +329,13 @@ end if o.orders.any? - collector << ' ' if o.partitions.any? + collector << SPACE if o.partitions.any? collector << "ORDER BY " collector = inject_join o.orders, collector, ", " end if o.framing - collector << ' ' if o.partitions.any? or o.orders.any? + collector << SPACE if o.partitions.any? or o.orders.any? collector = visit o.framing, collector end @@ -564,7 +544,7 @@ collector = visit o.left, collector end if o.right.any? - collector << " " if o.left + collector << SPACE if o.left collector = inject_join o.right, collector, ' ' end collector @@ -708,6 +688,35 @@ visit o.right, collector end + def visit_Arel_Nodes_Case o, collector + collector << "CASE " + if o.case + visit o.case, collector + collector << " " + end + o.conditions.each do |condition| + visit condition, collector + collector << " " + end + if o.default + visit o.default, collector + collector << " " + end + collector << "END" + end + + def visit_Arel_Nodes_When o, collector + collector << "WHEN " + visit o.left, collector + collector << " THEN " + visit o.right, collector + end + + def visit_Arel_Nodes_Else o, collector + collector << "ELSE " + visit o.expr, collector + end + def visit_Arel_Nodes_UnqualifiedColumn o, collector collector << "#{quote_column_name o.name}" collector @@ -733,6 +742,7 @@ alias :visit_Arel_Nodes_SqlLiteral :literal alias :visit_Bignum :literal alias :visit_Fixnum :literal + alias :visit_Integer :literal def quoted o, a if a && a.able_to_type_cast? @@ -772,6 +782,11 @@ alias :visit_Arel_Nodes_Multiplication :visit_Arel_Nodes_InfixOperation alias :visit_Arel_Nodes_Division :visit_Arel_Nodes_InfixOperation + def visit_Arel_Nodes_UnaryOperation o, collector + collector << " #{o.operator} " + visit o.expr, collector + end + def visit_Array o, collector inject_join o, collector, ", " end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/arel/visitors.rb new/lib/arel/visitors.rb --- old/lib/arel/visitors.rb 2015-12-17 21:03:57.000000000 +0100 +++ new/lib/arel/visitors.rb 2016-07-28 01:17:50.000000000 +0200 @@ -14,28 +14,5 @@ module Arel module Visitors - VISITORS = { - 'postgresql' => Arel::Visitors::PostgreSQL, - 'mysql' => Arel::Visitors::MySQL, - 'mysql2' => Arel::Visitors::MySQL, - 'mssql' => Arel::Visitors::MSSQL, - 'sqlserver' => Arel::Visitors::MSSQL, - 'oracle_enhanced' => Arel::Visitors::Oracle, - 'sqlite' => Arel::Visitors::SQLite, - 'sqlite3' => Arel::Visitors::SQLite, - 'ibm_db' => Arel::Visitors::IBM_DB, - 'informix' => Arel::Visitors::Informix, - } - - ENGINE_VISITORS = Hash.new do |hash, engine| - pool = engine.connection_pool - adapter = pool.spec.config[:adapter] - hash[engine] = (VISITORS[adapter] || Visitors::ToSql).new(engine) - end - - def self.visitor_for engine - ENGINE_VISITORS[engine] - end - class << self; alias :for :visitor_for; end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/arel.rb new/lib/arel.rb --- old/lib/arel.rb 2015-12-17 21:03:56.000000000 +0100 +++ new/lib/arel.rb 2016-07-28 01:17:50.000000000 +0200 @@ -21,7 +21,7 @@ require 'arel/nodes' module Arel - VERSION = '7.0.0' + VERSION = '7.1.1' def self.sql raw_sql Arel::Nodes::SqlLiteral.new raw_sql diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2015-12-17 21:03:56.000000000 +0100 +++ new/metadata 2016-07-28 01:17:50.000000000 +0200 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: arel version: !ruby/object:Gem::Version - version: 7.0.0 + version: 7.1.1 platform: ruby authors: - Aaron Patterson @@ -11,7 +11,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2015-12-17 00:00:00.000000000 Z +date: 2016-07-27 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: minitest @@ -75,11 +75,11 @@ extra_rdoc_files: - History.txt - MIT-LICENSE.txt -- README.markdown +- README.md files: - History.txt - MIT-LICENSE.txt -- README.markdown +- README.md - lib/arel.rb - lib/arel/alias_predication.rb - lib/arel/attributes.rb @@ -99,6 +99,7 @@ - lib/arel/nodes/ascending.rb - lib/arel/nodes/binary.rb - lib/arel/nodes/bind_param.rb +- lib/arel/nodes/case.rb - lib/arel/nodes/casted.rb - lib/arel/nodes/count.rb - lib/arel/nodes/delete_statement.rb @@ -129,6 +130,7 @@ - lib/arel/nodes/terminal.rb - lib/arel/nodes/true.rb - lib/arel/nodes/unary.rb +- lib/arel/nodes/unary_operation.rb - lib/arel/nodes/unqualified_column.rb - lib/arel/nodes/update_statement.rb - lib/arel/nodes/values.rb @@ -165,7 +167,7 @@ post_install_message: rdoc_options: - "--main" -- README.markdown +- README.md require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement @@ -180,7 +182,7 @@ version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.4.5.1 +rubygems_version: 2.6.6 signing_key: specification_version: 4 summary: Arel Really Exasperates Logicians Arel is a SQL AST manager for Ruby
