arel 3.0.0 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +4 -3
- data/History.txt +51 -0
- data/Manifest.txt +8 -0
- data/README.markdown +1 -1
- data/arel.gemspec +27 -16
- data/lib/arel.rb +2 -1
- data/lib/arel/expressions.rb +4 -0
- data/lib/arel/nodes.rb +5 -0
- data/lib/arel/nodes/extract.rb +23 -0
- data/lib/arel/nodes/function.rb +1 -0
- data/lib/arel/nodes/node.rb +1 -1
- data/lib/arel/nodes/over.rb +15 -0
- data/lib/arel/nodes/select_core.rb +3 -1
- data/lib/arel/nodes/sql_literal.rb +3 -0
- data/lib/arel/nodes/window.rb +78 -0
- data/lib/arel/select_manager.rb +6 -0
- data/lib/arel/visitors/bind_visitor.rb +24 -0
- data/lib/arel/visitors/depth_first.rb +4 -0
- data/lib/arel/visitors/dot.rb +26 -0
- data/lib/arel/visitors/informix.rb +1 -1
- data/lib/arel/visitors/to_sql.rb +71 -4
- data/lib/arel/window_predications.rb +9 -0
- data/test/nodes/test_extract.rb +19 -0
- data/test/nodes/test_node.rb +1 -0
- data/test/nodes/test_over.rb +49 -0
- data/test/test_select_manager.rb +156 -0
- data/test/visitors/test_bind_visitor.rb +39 -0
- data/test/visitors/test_depth_first.rb +10 -2
- data/test/visitors/test_informix.rb +10 -0
- data/test/visitors/test_oracle.rb +1 -1
- data/test/visitors/test_to_sql.rb +10 -8
- metadata +95 -47
data/Gemfile
CHANGED
@@ -2,10 +2,11 @@
|
|
2
2
|
|
3
3
|
# DO NOT EDIT THIS FILE. Instead, edit Rakefile, and run `rake bundler:gemfile`.
|
4
4
|
|
5
|
-
source
|
5
|
+
source "https://rubygems.org/"
|
6
6
|
|
7
7
|
|
8
|
-
gem "minitest", "~>
|
9
|
-
gem "
|
8
|
+
gem "minitest", "~>4.7", :group => [:development, :test]
|
9
|
+
gem "rdoc", "~>4.0", :group => [:development, :test]
|
10
|
+
gem "hoe", "~>3.6", :group => [:development, :test]
|
10
11
|
|
11
12
|
# vim: syntax=ruby
|
data/History.txt
CHANGED
@@ -1,3 +1,54 @@
|
|
1
|
+
== 3.0.3 / 2013-11-12
|
2
|
+
|
3
|
+
* Enhancements
|
4
|
+
|
5
|
+
* Support ANSI 2003 window functions
|
6
|
+
|
7
|
+
* Bug Fixes
|
8
|
+
|
9
|
+
* Fix joins in Informix
|
10
|
+
|
11
|
+
== 3.0.2 / 2012-02-21
|
12
|
+
|
13
|
+
* Enhancements
|
14
|
+
|
15
|
+
* Added a module for visiting and transforming bind values
|
16
|
+
* Fix in [] to be false, not in [] to be true
|
17
|
+
|
18
|
+
* Bug Fixes
|
19
|
+
|
20
|
+
* Revert fix for LIMIT / OFFSET when query is ordered in Oracle
|
21
|
+
|
22
|
+
== 3.0.1 / 2012-02-17
|
23
|
+
|
24
|
+
* Bug Fixes
|
25
|
+
|
26
|
+
* Fixed LIMIT / OFFSET when query is ordered in Oracle
|
27
|
+
|
28
|
+
== 3.0.0 / 2012-01-12
|
29
|
+
|
30
|
+
* Enhancements
|
31
|
+
|
32
|
+
* Support connection pool and schema cache
|
33
|
+
|
34
|
+
* Bug Fixes
|
35
|
+
|
36
|
+
* Conditions with no column can be followed by other conditions in Postgres
|
37
|
+
|
38
|
+
== 2.2.3 / 2012-02-21
|
39
|
+
|
40
|
+
* Enhancements
|
41
|
+
|
42
|
+
* Added a module for visiting and transforming bind values
|
43
|
+
|
44
|
+
== 2.2.2 / 2012-02-20
|
45
|
+
|
46
|
+
* Enhancements
|
47
|
+
|
48
|
+
* Support LOCK
|
49
|
+
* Allow using non-table alias as a right-hand relation name
|
50
|
+
* Added SelectManager#distinct
|
51
|
+
|
1
52
|
== 2.2.1 / 2011-09-15
|
2
53
|
|
3
54
|
* Enhancements
|
data/Manifest.txt
CHANGED
@@ -29,6 +29,7 @@ lib/arel/nodes/count.rb
|
|
29
29
|
lib/arel/nodes/delete_statement.rb
|
30
30
|
lib/arel/nodes/descending.rb
|
31
31
|
lib/arel/nodes/equality.rb
|
32
|
+
lib/arel/nodes/extract.rb
|
32
33
|
lib/arel/nodes/false.rb
|
33
34
|
lib/arel/nodes/function.rb
|
34
35
|
lib/arel/nodes/in.rb
|
@@ -40,6 +41,7 @@ lib/arel/nodes/named_function.rb
|
|
40
41
|
lib/arel/nodes/node.rb
|
41
42
|
lib/arel/nodes/ordering.rb
|
42
43
|
lib/arel/nodes/outer_join.rb
|
44
|
+
lib/arel/nodes/over.rb
|
43
45
|
lib/arel/nodes/select_core.rb
|
44
46
|
lib/arel/nodes/select_statement.rb
|
45
47
|
lib/arel/nodes/sql_literal.rb
|
@@ -51,6 +53,7 @@ lib/arel/nodes/unary.rb
|
|
51
53
|
lib/arel/nodes/unqualified_column.rb
|
52
54
|
lib/arel/nodes/update_statement.rb
|
53
55
|
lib/arel/nodes/values.rb
|
56
|
+
lib/arel/nodes/window.rb
|
54
57
|
lib/arel/nodes/with.rb
|
55
58
|
lib/arel/order_predications.rb
|
56
59
|
lib/arel/predications.rb
|
@@ -62,6 +65,7 @@ lib/arel/table.rb
|
|
62
65
|
lib/arel/tree_manager.rb
|
63
66
|
lib/arel/update_manager.rb
|
64
67
|
lib/arel/visitors.rb
|
68
|
+
lib/arel/visitors/bind_visitor.rb
|
65
69
|
lib/arel/visitors/depth_first.rb
|
66
70
|
lib/arel/visitors/dot.rb
|
67
71
|
lib/arel/visitors/ibm_db.rb
|
@@ -76,6 +80,7 @@ lib/arel/visitors/sqlite.rb
|
|
76
80
|
lib/arel/visitors/to_sql.rb
|
77
81
|
lib/arel/visitors/visitor.rb
|
78
82
|
lib/arel/visitors/where_sql.rb
|
83
|
+
lib/arel/window_predications.rb
|
79
84
|
test/attributes/test_attribute.rb
|
80
85
|
test/helper.rb
|
81
86
|
test/nodes/test_as.rb
|
@@ -85,12 +90,14 @@ test/nodes/test_count.rb
|
|
85
90
|
test/nodes/test_delete_statement.rb
|
86
91
|
test/nodes/test_descending.rb
|
87
92
|
test/nodes/test_equality.rb
|
93
|
+
test/nodes/test_extract.rb
|
88
94
|
test/nodes/test_infix_operation.rb
|
89
95
|
test/nodes/test_insert_statement.rb
|
90
96
|
test/nodes/test_named_function.rb
|
91
97
|
test/nodes/test_node.rb
|
92
98
|
test/nodes/test_not.rb
|
93
99
|
test/nodes/test_or.rb
|
100
|
+
test/nodes/test_over.rb
|
94
101
|
test/nodes/test_select_core.rb
|
95
102
|
test/nodes/test_select_statement.rb
|
96
103
|
test/nodes/test_sql_literal.rb
|
@@ -106,6 +113,7 @@ test/test_insert_manager.rb
|
|
106
113
|
test/test_select_manager.rb
|
107
114
|
test/test_table.rb
|
108
115
|
test/test_update_manager.rb
|
116
|
+
test/visitors/test_bind_visitor.rb
|
109
117
|
test/visitors/test_depth_first.rb
|
110
118
|
test/visitors/test_dot.rb
|
111
119
|
test/visitors/test_ibm_db.rb
|
data/README.markdown
CHANGED
@@ -83,7 +83,7 @@ The examples above are fairly simple and other libraries match or come close to
|
|
83
83
|
|
84
84
|
#### Inline math operations
|
85
85
|
|
86
|
-
Suppose we have a table `products` with prices in different currencies. And we have a table currency_rates
|
86
|
+
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:
|
87
87
|
|
88
88
|
products = Arel::Table.new(:products)
|
89
89
|
products.columns # => [products[:id], products[:name], products[:price], products[:currency_id]]
|
data/arel.gemspec
CHANGED
@@ -1,36 +1,47 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
s.name =
|
5
|
-
s.version = "3.0.
|
4
|
+
s.name = %q{arel}
|
5
|
+
s.version = "3.0.3.20131114190737"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Aaron Patterson", "Bryan Halmkamp", "Emilio Tagua", "Nick Kallen"]
|
9
|
-
s.date =
|
10
|
-
s.description =
|
9
|
+
s.date = %q{2013-11-14}
|
10
|
+
s.description = %q{Arel is a SQL AST manager for Ruby. It
|
11
|
+
|
12
|
+
1. Simplifies the generation of complex SQL queries
|
13
|
+
2. Adapts to various RDBMS systems
|
14
|
+
|
15
|
+
It is intended to be a framework framework; that is, you can build your own ORM
|
16
|
+
with it, focusing on innovative object and collection modeling as opposed to
|
17
|
+
database compatibility and query generation.}
|
11
18
|
s.email = ["aaron@tenderlovemaking.com", "bryan@brynary.com", "miloops@gmail.com", "nick@example.org"]
|
12
19
|
s.extra_rdoc_files = ["History.txt", "MIT-LICENSE.txt", "Manifest.txt", "README.markdown"]
|
13
|
-
s.files = [".autotest", ".gemtest", ".travis.yml", "Gemfile", "History.txt", "MIT-LICENSE.txt", "Manifest.txt", "README.markdown", "Rakefile", "arel.gemspec", "lib/arel.rb", "lib/arel/alias_predication.rb", "lib/arel/attributes.rb", "lib/arel/attributes/attribute.rb", "lib/arel/compatibility/wheres.rb", "lib/arel/crud.rb", "lib/arel/delete_manager.rb", "lib/arel/deprecated.rb", "lib/arel/expression.rb", "lib/arel/expressions.rb", "lib/arel/factory_methods.rb", "lib/arel/insert_manager.rb", "lib/arel/math.rb", "lib/arel/nodes.rb", "lib/arel/nodes/and.rb", "lib/arel/nodes/ascending.rb", "lib/arel/nodes/binary.rb", "lib/arel/nodes/count.rb", "lib/arel/nodes/delete_statement.rb", "lib/arel/nodes/descending.rb", "lib/arel/nodes/equality.rb", "lib/arel/nodes/false.rb", "lib/arel/nodes/function.rb", "lib/arel/nodes/in.rb", "lib/arel/nodes/infix_operation.rb", "lib/arel/nodes/inner_join.rb", "lib/arel/nodes/insert_statement.rb", "lib/arel/nodes/join_source.rb", "lib/arel/nodes/named_function.rb", "lib/arel/nodes/node.rb", "lib/arel/nodes/ordering.rb", "lib/arel/nodes/outer_join.rb", "lib/arel/nodes/select_core.rb", "lib/arel/nodes/select_statement.rb", "lib/arel/nodes/sql_literal.rb", "lib/arel/nodes/string_join.rb", "lib/arel/nodes/table_alias.rb", "lib/arel/nodes/terminal.rb", "lib/arel/nodes/true.rb", "lib/arel/nodes/unary.rb", "lib/arel/nodes/unqualified_column.rb", "lib/arel/nodes/update_statement.rb", "lib/arel/nodes/values.rb", "lib/arel/nodes/with.rb", "lib/arel/order_predications.rb", "lib/arel/predications.rb", "lib/arel/relation.rb", "lib/arel/select_manager.rb", "lib/arel/sql/engine.rb", "lib/arel/sql_literal.rb", "lib/arel/table.rb", "lib/arel/tree_manager.rb", "lib/arel/update_manager.rb", "lib/arel/visitors.rb", "lib/arel/visitors/depth_first.rb", "lib/arel/visitors/dot.rb", "lib/arel/visitors/ibm_db.rb", "lib/arel/visitors/informix.rb", "lib/arel/visitors/join_sql.rb", "lib/arel/visitors/mssql.rb", "lib/arel/visitors/mysql.rb", "lib/arel/visitors/oracle.rb", "lib/arel/visitors/order_clauses.rb", "lib/arel/visitors/postgresql.rb", "lib/arel/visitors/sqlite.rb", "lib/arel/visitors/to_sql.rb", "lib/arel/visitors/visitor.rb", "lib/arel/visitors/where_sql.rb", "test/attributes/test_attribute.rb", "test/helper.rb", "test/nodes/test_as.rb", "test/nodes/test_ascending.rb", "test/nodes/test_bin.rb", "test/nodes/test_count.rb", "test/nodes/test_delete_statement.rb", "test/nodes/test_descending.rb", "test/nodes/test_equality.rb", "test/nodes/test_infix_operation.rb", "test/nodes/test_insert_statement.rb", "test/nodes/test_named_function.rb", "test/nodes/test_node.rb", "test/nodes/test_not.rb", "test/nodes/test_or.rb", "test/nodes/test_select_core.rb", "test/nodes/test_select_statement.rb", "test/nodes/test_sql_literal.rb", "test/nodes/test_sum.rb", "test/nodes/test_update_statement.rb", "test/support/fake_record.rb", "test/test_activerecord_compat.rb", "test/test_attributes.rb", "test/test_crud.rb", "test/test_delete_manager.rb", "test/test_factory_methods.rb", "test/test_insert_manager.rb", "test/test_select_manager.rb", "test/test_table.rb", "test/test_update_manager.rb", "test/visitors/test_depth_first.rb", "test/visitors/test_dot.rb", "test/visitors/test_ibm_db.rb", "test/visitors/test_informix.rb", "test/visitors/test_join_sql.rb", "test/visitors/test_mssql.rb", "test/visitors/test_mysql.rb", "test/visitors/test_oracle.rb", "test/visitors/test_postgres.rb", "test/visitors/test_sqlite.rb", "test/visitors/test_to_sql.rb"]
|
14
|
-
s.homepage =
|
20
|
+
s.files = [".autotest", ".gemtest", ".travis.yml", "Gemfile", "History.txt", "MIT-LICENSE.txt", "Manifest.txt", "README.markdown", "Rakefile", "arel.gemspec", "lib/arel.rb", "lib/arel/alias_predication.rb", "lib/arel/attributes.rb", "lib/arel/attributes/attribute.rb", "lib/arel/compatibility/wheres.rb", "lib/arel/crud.rb", "lib/arel/delete_manager.rb", "lib/arel/deprecated.rb", "lib/arel/expression.rb", "lib/arel/expressions.rb", "lib/arel/factory_methods.rb", "lib/arel/insert_manager.rb", "lib/arel/math.rb", "lib/arel/nodes.rb", "lib/arel/nodes/and.rb", "lib/arel/nodes/ascending.rb", "lib/arel/nodes/binary.rb", "lib/arel/nodes/count.rb", "lib/arel/nodes/delete_statement.rb", "lib/arel/nodes/descending.rb", "lib/arel/nodes/equality.rb", "lib/arel/nodes/extract.rb", "lib/arel/nodes/false.rb", "lib/arel/nodes/function.rb", "lib/arel/nodes/in.rb", "lib/arel/nodes/infix_operation.rb", "lib/arel/nodes/inner_join.rb", "lib/arel/nodes/insert_statement.rb", "lib/arel/nodes/join_source.rb", "lib/arel/nodes/named_function.rb", "lib/arel/nodes/node.rb", "lib/arel/nodes/ordering.rb", "lib/arel/nodes/outer_join.rb", "lib/arel/nodes/over.rb", "lib/arel/nodes/select_core.rb", "lib/arel/nodes/select_statement.rb", "lib/arel/nodes/sql_literal.rb", "lib/arel/nodes/string_join.rb", "lib/arel/nodes/table_alias.rb", "lib/arel/nodes/terminal.rb", "lib/arel/nodes/true.rb", "lib/arel/nodes/unary.rb", "lib/arel/nodes/unqualified_column.rb", "lib/arel/nodes/update_statement.rb", "lib/arel/nodes/values.rb", "lib/arel/nodes/window.rb", "lib/arel/nodes/with.rb", "lib/arel/order_predications.rb", "lib/arel/predications.rb", "lib/arel/relation.rb", "lib/arel/select_manager.rb", "lib/arel/sql/engine.rb", "lib/arel/sql_literal.rb", "lib/arel/table.rb", "lib/arel/tree_manager.rb", "lib/arel/update_manager.rb", "lib/arel/visitors.rb", "lib/arel/visitors/bind_visitor.rb", "lib/arel/visitors/depth_first.rb", "lib/arel/visitors/dot.rb", "lib/arel/visitors/ibm_db.rb", "lib/arel/visitors/informix.rb", "lib/arel/visitors/join_sql.rb", "lib/arel/visitors/mssql.rb", "lib/arel/visitors/mysql.rb", "lib/arel/visitors/oracle.rb", "lib/arel/visitors/order_clauses.rb", "lib/arel/visitors/postgresql.rb", "lib/arel/visitors/sqlite.rb", "lib/arel/visitors/to_sql.rb", "lib/arel/visitors/visitor.rb", "lib/arel/visitors/where_sql.rb", "lib/arel/window_predications.rb", "test/attributes/test_attribute.rb", "test/helper.rb", "test/nodes/test_as.rb", "test/nodes/test_ascending.rb", "test/nodes/test_bin.rb", "test/nodes/test_count.rb", "test/nodes/test_delete_statement.rb", "test/nodes/test_descending.rb", "test/nodes/test_equality.rb", "test/nodes/test_extract.rb", "test/nodes/test_infix_operation.rb", "test/nodes/test_insert_statement.rb", "test/nodes/test_named_function.rb", "test/nodes/test_node.rb", "test/nodes/test_not.rb", "test/nodes/test_or.rb", "test/nodes/test_over.rb", "test/nodes/test_select_core.rb", "test/nodes/test_select_statement.rb", "test/nodes/test_sql_literal.rb", "test/nodes/test_sum.rb", "test/nodes/test_update_statement.rb", "test/support/fake_record.rb", "test/test_activerecord_compat.rb", "test/test_attributes.rb", "test/test_crud.rb", "test/test_delete_manager.rb", "test/test_factory_methods.rb", "test/test_insert_manager.rb", "test/test_select_manager.rb", "test/test_table.rb", "test/test_update_manager.rb", "test/visitors/test_bind_visitor.rb", "test/visitors/test_depth_first.rb", "test/visitors/test_dot.rb", "test/visitors/test_ibm_db.rb", "test/visitors/test_informix.rb", "test/visitors/test_join_sql.rb", "test/visitors/test_mssql.rb", "test/visitors/test_mysql.rb", "test/visitors/test_oracle.rb", "test/visitors/test_postgres.rb", "test/visitors/test_sqlite.rb", "test/visitors/test_to_sql.rb"]
|
21
|
+
s.homepage = %q{http://github.com/rails/arel}
|
22
|
+
s.licenses = ["MIT"]
|
15
23
|
s.rdoc_options = ["--main", "README.markdown"]
|
16
24
|
s.require_paths = ["lib"]
|
17
|
-
s.rubyforge_project =
|
18
|
-
s.rubygems_version =
|
19
|
-
s.summary =
|
20
|
-
s.test_files = ["test/attributes/test_attribute.rb", "test/nodes/test_as.rb", "test/nodes/test_ascending.rb", "test/nodes/test_bin.rb", "test/nodes/test_count.rb", "test/nodes/test_delete_statement.rb", "test/nodes/test_descending.rb", "test/nodes/test_equality.rb", "test/nodes/test_infix_operation.rb", "test/nodes/test_insert_statement.rb", "test/nodes/test_named_function.rb", "test/nodes/test_node.rb", "test/nodes/test_not.rb", "test/nodes/test_or.rb", "test/nodes/test_select_core.rb", "test/nodes/test_select_statement.rb", "test/nodes/test_sql_literal.rb", "test/nodes/test_sum.rb", "test/nodes/test_update_statement.rb", "test/test_activerecord_compat.rb", "test/test_attributes.rb", "test/test_crud.rb", "test/test_delete_manager.rb", "test/test_factory_methods.rb", "test/test_insert_manager.rb", "test/test_select_manager.rb", "test/test_table.rb", "test/test_update_manager.rb", "test/visitors/test_depth_first.rb", "test/visitors/test_dot.rb", "test/visitors/test_ibm_db.rb", "test/visitors/test_informix.rb", "test/visitors/test_join_sql.rb", "test/visitors/test_mssql.rb", "test/visitors/test_mysql.rb", "test/visitors/test_oracle.rb", "test/visitors/test_postgres.rb", "test/visitors/test_sqlite.rb", "test/visitors/test_to_sql.rb"]
|
25
|
+
s.rubyforge_project = %q{arel}
|
26
|
+
s.rubygems_version = %q{1.6.2}
|
27
|
+
s.summary = %q{Arel is a SQL AST manager for Ruby}
|
28
|
+
s.test_files = ["test/attributes/test_attribute.rb", "test/nodes/test_as.rb", "test/nodes/test_ascending.rb", "test/nodes/test_bin.rb", "test/nodes/test_count.rb", "test/nodes/test_delete_statement.rb", "test/nodes/test_descending.rb", "test/nodes/test_equality.rb", "test/nodes/test_extract.rb", "test/nodes/test_infix_operation.rb", "test/nodes/test_insert_statement.rb", "test/nodes/test_named_function.rb", "test/nodes/test_node.rb", "test/nodes/test_not.rb", "test/nodes/test_or.rb", "test/nodes/test_over.rb", "test/nodes/test_select_core.rb", "test/nodes/test_select_statement.rb", "test/nodes/test_sql_literal.rb", "test/nodes/test_sum.rb", "test/nodes/test_update_statement.rb", "test/test_activerecord_compat.rb", "test/test_attributes.rb", "test/test_crud.rb", "test/test_delete_manager.rb", "test/test_factory_methods.rb", "test/test_insert_manager.rb", "test/test_select_manager.rb", "test/test_table.rb", "test/test_update_manager.rb", "test/visitors/test_bind_visitor.rb", "test/visitors/test_depth_first.rb", "test/visitors/test_dot.rb", "test/visitors/test_ibm_db.rb", "test/visitors/test_informix.rb", "test/visitors/test_join_sql.rb", "test/visitors/test_mssql.rb", "test/visitors/test_mysql.rb", "test/visitors/test_oracle.rb", "test/visitors/test_postgres.rb", "test/visitors/test_sqlite.rb", "test/visitors/test_to_sql.rb"]
|
21
29
|
|
22
30
|
if s.respond_to? :specification_version then
|
23
31
|
s.specification_version = 3
|
24
32
|
|
25
33
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
-
s.add_development_dependency(%q<
|
27
|
-
s.add_development_dependency(%q<rdoc>, ["~>
|
34
|
+
s.add_development_dependency(%q<minitest>, ["~> 4.7"])
|
35
|
+
s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
|
36
|
+
s.add_development_dependency(%q<hoe>, ["~> 3.7"])
|
28
37
|
else
|
29
|
-
s.add_dependency(%q<
|
30
|
-
s.add_dependency(%q<rdoc>, ["~>
|
38
|
+
s.add_dependency(%q<minitest>, ["~> 4.7"])
|
39
|
+
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
40
|
+
s.add_dependency(%q<hoe>, ["~> 3.7"])
|
31
41
|
end
|
32
42
|
else
|
33
|
-
s.add_dependency(%q<
|
34
|
-
s.add_dependency(%q<rdoc>, ["~>
|
43
|
+
s.add_dependency(%q<minitest>, ["~> 4.7"])
|
44
|
+
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
45
|
+
s.add_dependency(%q<hoe>, ["~> 3.7"])
|
35
46
|
end
|
36
47
|
end
|
data/lib/arel.rb
CHANGED
@@ -3,6 +3,7 @@ require 'arel/factory_methods'
|
|
3
3
|
|
4
4
|
require 'arel/expressions'
|
5
5
|
require 'arel/predications'
|
6
|
+
require 'arel/window_predications'
|
6
7
|
require 'arel/math'
|
7
8
|
require 'arel/alias_predication'
|
8
9
|
require 'arel/order_predications'
|
@@ -33,7 +34,7 @@ require 'arel/sql_literal'
|
|
33
34
|
####
|
34
35
|
|
35
36
|
module Arel
|
36
|
-
VERSION = '3.0.
|
37
|
+
VERSION = '3.0.3'
|
37
38
|
|
38
39
|
def self.sql raw_sql
|
39
40
|
Arel::Nodes::SqlLiteral.new raw_sql
|
data/lib/arel/expressions.rb
CHANGED
data/lib/arel/nodes.rb
CHANGED
@@ -26,6 +26,7 @@ require 'arel/nodes/join_source'
|
|
26
26
|
require 'arel/nodes/delete_statement'
|
27
27
|
require 'arel/nodes/table_alias'
|
28
28
|
require 'arel/nodes/infix_operation'
|
29
|
+
require 'arel/nodes/over'
|
29
30
|
|
30
31
|
# nary
|
31
32
|
require 'arel/nodes/and'
|
@@ -35,9 +36,13 @@ require 'arel/nodes/and'
|
|
35
36
|
# We should make Function a Unary node and deprecate the use of "aliaz"
|
36
37
|
require 'arel/nodes/function'
|
37
38
|
require 'arel/nodes/count'
|
39
|
+
require 'arel/nodes/extract'
|
38
40
|
require 'arel/nodes/values'
|
39
41
|
require 'arel/nodes/named_function'
|
40
42
|
|
43
|
+
# windows
|
44
|
+
require 'arel/nodes/window'
|
45
|
+
|
41
46
|
# joins
|
42
47
|
require 'arel/nodes/inner_join'
|
43
48
|
require 'arel/nodes/outer_join'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Arel
|
2
|
+
module Nodes
|
3
|
+
|
4
|
+
class Extract < Arel::Nodes::Unary
|
5
|
+
include Arel::Expression
|
6
|
+
include Arel::Predications
|
7
|
+
|
8
|
+
attr_accessor :field
|
9
|
+
attr_accessor :alias
|
10
|
+
|
11
|
+
def initialize expr, field, aliaz = nil
|
12
|
+
super(expr)
|
13
|
+
@field = field
|
14
|
+
@alias = aliaz && SqlLiteral.new(aliaz)
|
15
|
+
end
|
16
|
+
|
17
|
+
def as aliaz
|
18
|
+
self.alias = SqlLiteral.new(aliaz)
|
19
|
+
self
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/arel/nodes/function.rb
CHANGED
data/lib/arel/nodes/node.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Arel
|
2
2
|
module Nodes
|
3
3
|
class SelectCore < Arel::Nodes::Node
|
4
|
-
attr_accessor :top, :projections, :wheres, :groups
|
4
|
+
attr_accessor :top, :projections, :wheres, :groups, :windows
|
5
5
|
attr_accessor :having, :source, :set_quantifier
|
6
6
|
|
7
7
|
def initialize
|
@@ -14,6 +14,7 @@ module Arel
|
|
14
14
|
@wheres = []
|
15
15
|
@groups = []
|
16
16
|
@having = nil
|
17
|
+
@windows = []
|
17
18
|
end
|
18
19
|
|
19
20
|
def from
|
@@ -34,6 +35,7 @@ module Arel
|
|
34
35
|
@wheres = @wheres.clone
|
35
36
|
@groups = @groups.clone
|
36
37
|
@having = @having.clone if @having
|
38
|
+
@windows = @windows.clone
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Arel
|
2
|
+
module Nodes
|
3
|
+
class Window < Arel::Nodes::Node
|
4
|
+
include Arel::Expression
|
5
|
+
attr_accessor :orders, :framing
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@orders = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def order *expr
|
12
|
+
# FIXME: We SHOULD NOT be converting these to SqlLiteral automatically
|
13
|
+
@orders.concat expr.map { |x|
|
14
|
+
String === x || Symbol === x ? Nodes::SqlLiteral.new(x.to_s) : x
|
15
|
+
}
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def frame(expr)
|
20
|
+
raise ArgumentError, "Window frame cannot be set more than once" if @frame
|
21
|
+
@framing = expr
|
22
|
+
end
|
23
|
+
|
24
|
+
def rows(expr = nil)
|
25
|
+
frame(Rows.new(expr))
|
26
|
+
end
|
27
|
+
|
28
|
+
def range(expr = nil)
|
29
|
+
frame(Range.new(expr))
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize_copy other
|
33
|
+
super
|
34
|
+
@orders = @orders.map { |x| x.clone }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class NamedWindow < Window
|
39
|
+
attr_accessor :name
|
40
|
+
|
41
|
+
def initialize name
|
42
|
+
super()
|
43
|
+
@name = name
|
44
|
+
end
|
45
|
+
|
46
|
+
def initialize_copy other
|
47
|
+
super
|
48
|
+
@name = other.name.clone
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class Rows < Unary
|
53
|
+
def initialize(expr = nil)
|
54
|
+
super(expr)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class Range < Unary
|
59
|
+
def initialize(expr = nil)
|
60
|
+
super(expr)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class CurrentRow < Arel::Nodes::Node; end
|
65
|
+
|
66
|
+
class Preceding < Unary
|
67
|
+
def initialize(expr = nil)
|
68
|
+
super(expr)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
class Following < Unary
|
73
|
+
def initialize(expr = nil)
|
74
|
+
super(expr)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/lib/arel/select_manager.rb
CHANGED
@@ -126,6 +126,12 @@ module Arel
|
|
126
126
|
self
|
127
127
|
end
|
128
128
|
|
129
|
+
def window name
|
130
|
+
window = Nodes::NamedWindow.new(name)
|
131
|
+
@ctx.windows.push window
|
132
|
+
window
|
133
|
+
end
|
134
|
+
|
129
135
|
def project *projections
|
130
136
|
# FIXME: converting these to SQLLiterals is probably not good, but
|
131
137
|
# rails tests require it.
|