arel 5.0.1.20140414130214 → 6.0.0.beta1
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.
- checksums.yaml +4 -4
- data/.travis.yml +4 -2
- data/History.txt +9 -4
- data/Manifest.txt +9 -7
- data/README.markdown +85 -8
- data/Rakefile +1 -1
- data/arel.gemspec +15 -16
- data/lib/arel.rb +1 -12
- data/lib/arel/collectors/bind.rb +36 -0
- data/lib/arel/collectors/plain_string.rb +18 -0
- data/lib/arel/collectors/sql_string.rb +18 -0
- data/lib/arel/factory_methods.rb +1 -1
- data/lib/arel/insert_manager.rb +5 -1
- data/lib/arel/nodes.rb +41 -0
- data/lib/arel/nodes/and.rb +1 -5
- data/lib/arel/nodes/binary.rb +2 -0
- data/lib/arel/nodes/extract.rb +0 -2
- data/lib/arel/nodes/full_outer_join.rb +6 -0
- data/lib/arel/nodes/function.rb +0 -1
- data/lib/arel/nodes/insert_statement.rb +5 -2
- data/lib/arel/nodes/node.rb +5 -1
- data/lib/arel/nodes/right_outer_join.rb +6 -0
- data/lib/arel/nodes/window.rb +23 -5
- data/lib/arel/predications.rb +41 -33
- data/lib/arel/select_manager.rb +13 -37
- data/lib/arel/table.rb +13 -9
- data/lib/arel/tree_manager.rb +8 -2
- data/lib/arel/update_manager.rb +2 -2
- data/lib/arel/visitors.rb +0 -2
- data/lib/arel/visitors/bind_substitute.rb +9 -0
- data/lib/arel/visitors/bind_visitor.rb +10 -5
- data/lib/arel/visitors/depth_first.rb +60 -57
- data/lib/arel/visitors/dot.rb +84 -80
- data/lib/arel/visitors/ibm_db.rb +4 -2
- data/lib/arel/visitors/informix.rb +39 -21
- data/lib/arel/visitors/mssql.rb +41 -23
- data/lib/arel/visitors/mysql.rb +48 -22
- data/lib/arel/visitors/oracle.rb +33 -24
- data/lib/arel/visitors/postgresql.rb +15 -8
- data/lib/arel/visitors/reduce.rb +25 -0
- data/lib/arel/visitors/sqlite.rb +3 -2
- data/lib/arel/visitors/to_sql.rb +455 -248
- data/lib/arel/visitors/visitor.rb +2 -2
- data/lib/arel/visitors/where_sql.rb +3 -2
- data/test/attributes/test_attribute.rb +12 -3
- data/test/collectors/test_bind_collector.rb +70 -0
- data/test/collectors/test_sql_string.rb +38 -0
- data/test/helper.rb +10 -1
- data/test/nodes/test_bin.rb +2 -2
- data/test/nodes/test_count.rb +0 -6
- data/test/nodes/test_equality.rb +1 -1
- data/test/nodes/test_grouping.rb +1 -1
- data/test/nodes/test_infix_operation.rb +1 -1
- data/test/nodes/test_select_core.rb +7 -7
- data/test/nodes/test_sql_literal.rb +10 -6
- data/test/nodes/test_window.rb +9 -3
- data/test/support/fake_record.rb +16 -4
- data/test/test_factory_methods.rb +1 -1
- data/test/test_insert_manager.rb +33 -4
- data/test/test_select_manager.rb +164 -92
- data/test/test_table.rb +49 -4
- data/test/visitors/test_bind_visitor.rb +18 -10
- data/test/visitors/test_depth_first.rb +12 -0
- data/test/visitors/test_dot.rb +4 -4
- data/test/visitors/test_ibm_db.rb +11 -5
- data/test/visitors/test_informix.rb +14 -8
- data/test/visitors/test_mssql.rb +12 -8
- data/test/visitors/test_mysql.rb +17 -12
- data/test/visitors/test_oracle.rb +25 -21
- data/test/visitors/test_postgres.rb +50 -12
- data/test/visitors/test_sqlite.rb +2 -2
- data/test/visitors/test_to_sql.rb +177 -81
- metadata +24 -19
- data/lib/arel/deprecated.rb +0 -4
- data/lib/arel/expression.rb +0 -5
- data/lib/arel/sql/engine.rb +0 -10
- data/lib/arel/sql_literal.rb +0 -4
- data/lib/arel/visitors/join_sql.rb +0 -19
- data/lib/arel/visitors/order_clauses.rb +0 -11
- data/test/visitors/test_join_sql.rb +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b103196a0f761d65ab71b2ac1e03d779de9e219d
|
4
|
+
data.tar.gz: 9cb4e0384586df861b130b6f64ad01c85235f1ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdb5378f5ea5baf01ec44da940498565dadfb2b044047d9ec98f62b5aebe9bc802f79194dcd0936451d41f90238b265e0b534e3fce2ba94951913f9ebf0b9e5f
|
7
|
+
data.tar.gz: 651a4dba661f193f62c98af603e6a313a354ee772ba5e17e8830b653ac2ef794485f9a1f39ca8ca8702bfd74d66bb12d9b0f436873be5ca885de93033ce7b6d9
|
data/.travis.yml
CHANGED
data/History.txt
CHANGED
@@ -1,9 +1,14 @@
|
|
1
|
-
|
1
|
+
=== NEXT / 2014-02-10
|
2
2
|
|
3
|
-
|
3
|
+
* Enhancements
|
4
4
|
|
5
|
-
*
|
6
|
-
*
|
5
|
+
* Remove deprecated `Arel::Expression`
|
6
|
+
* Remove deprecated `Arel::SqlLiteral`
|
7
|
+
* Remove deprecated `SelectManager#joins`
|
8
|
+
* Remove deprecated `SelectManager#to_a`
|
9
|
+
* Remove deprecated `Arel::Sql::Engine`
|
10
|
+
* Remove deprecated `Arel::InnerJoin` constant
|
11
|
+
* Remove deprecated `Arel::OuterJoin` constant
|
7
12
|
|
8
13
|
== 5.0.0 / 2013-12-04
|
9
14
|
|
data/Manifest.txt
CHANGED
@@ -12,11 +12,12 @@ lib/arel.rb
|
|
12
12
|
lib/arel/alias_predication.rb
|
13
13
|
lib/arel/attributes.rb
|
14
14
|
lib/arel/attributes/attribute.rb
|
15
|
+
lib/arel/collectors/bind.rb
|
16
|
+
lib/arel/collectors/plain_string.rb
|
17
|
+
lib/arel/collectors/sql_string.rb
|
15
18
|
lib/arel/compatibility/wheres.rb
|
16
19
|
lib/arel/crud.rb
|
17
20
|
lib/arel/delete_manager.rb
|
18
|
-
lib/arel/deprecated.rb
|
19
|
-
lib/arel/expression.rb
|
20
21
|
lib/arel/expressions.rb
|
21
22
|
lib/arel/factory_methods.rb
|
22
23
|
lib/arel/insert_manager.rb
|
@@ -31,6 +32,7 @@ lib/arel/nodes/descending.rb
|
|
31
32
|
lib/arel/nodes/equality.rb
|
32
33
|
lib/arel/nodes/extract.rb
|
33
34
|
lib/arel/nodes/false.rb
|
35
|
+
lib/arel/nodes/full_outer_join.rb
|
34
36
|
lib/arel/nodes/function.rb
|
35
37
|
lib/arel/nodes/grouping.rb
|
36
38
|
lib/arel/nodes/in.rb
|
@@ -42,6 +44,7 @@ lib/arel/nodes/named_function.rb
|
|
42
44
|
lib/arel/nodes/node.rb
|
43
45
|
lib/arel/nodes/outer_join.rb
|
44
46
|
lib/arel/nodes/over.rb
|
47
|
+
lib/arel/nodes/right_outer_join.rb
|
45
48
|
lib/arel/nodes/select_core.rb
|
46
49
|
lib/arel/nodes/select_statement.rb
|
47
50
|
lib/arel/nodes/sql_literal.rb
|
@@ -58,29 +61,29 @@ lib/arel/nodes/with.rb
|
|
58
61
|
lib/arel/order_predications.rb
|
59
62
|
lib/arel/predications.rb
|
60
63
|
lib/arel/select_manager.rb
|
61
|
-
lib/arel/sql/engine.rb
|
62
|
-
lib/arel/sql_literal.rb
|
63
64
|
lib/arel/table.rb
|
64
65
|
lib/arel/tree_manager.rb
|
65
66
|
lib/arel/update_manager.rb
|
66
67
|
lib/arel/visitors.rb
|
68
|
+
lib/arel/visitors/bind_substitute.rb
|
67
69
|
lib/arel/visitors/bind_visitor.rb
|
68
70
|
lib/arel/visitors/depth_first.rb
|
69
71
|
lib/arel/visitors/dot.rb
|
70
72
|
lib/arel/visitors/ibm_db.rb
|
71
73
|
lib/arel/visitors/informix.rb
|
72
|
-
lib/arel/visitors/join_sql.rb
|
73
74
|
lib/arel/visitors/mssql.rb
|
74
75
|
lib/arel/visitors/mysql.rb
|
75
76
|
lib/arel/visitors/oracle.rb
|
76
|
-
lib/arel/visitors/order_clauses.rb
|
77
77
|
lib/arel/visitors/postgresql.rb
|
78
|
+
lib/arel/visitors/reduce.rb
|
78
79
|
lib/arel/visitors/sqlite.rb
|
79
80
|
lib/arel/visitors/to_sql.rb
|
80
81
|
lib/arel/visitors/visitor.rb
|
81
82
|
lib/arel/visitors/where_sql.rb
|
82
83
|
lib/arel/window_predications.rb
|
83
84
|
test/attributes/test_attribute.rb
|
85
|
+
test/collectors/test_bind_collector.rb
|
86
|
+
test/collectors/test_sql_string.rb
|
84
87
|
test/helper.rb
|
85
88
|
test/nodes/test_and.rb
|
86
89
|
test/nodes/test_as.rb
|
@@ -124,7 +127,6 @@ test/visitors/test_dispatch_contamination.rb
|
|
124
127
|
test/visitors/test_dot.rb
|
125
128
|
test/visitors/test_ibm_db.rb
|
126
129
|
test/visitors/test_informix.rb
|
127
|
-
test/visitors/test_join_sql.rb
|
128
130
|
test/visitors/test_mssql.rb
|
129
131
|
test/visitors/test_mysql.rb
|
130
132
|
test/visitors/test_oracle.rb
|
data/README.markdown
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
# Arel [](http://travis-ci.org/rails/arel) [](https://gemnasium.com/rails/arel)
|
2
2
|
|
3
3
|
* http://github.com/rails/arel
|
4
4
|
|
5
5
|
## DESCRIPTION
|
6
6
|
|
7
|
+
Arel Really Exasperates Logicians
|
8
|
+
|
7
9
|
Arel is a SQL AST manager for Ruby. It
|
8
10
|
|
9
11
|
1. Simplifies the generation of complex SQL queries
|
@@ -35,7 +37,7 @@ query.to_sql
|
|
35
37
|
|
36
38
|
### More Sophisticated Queries
|
37
39
|
|
38
|
-
Here is a whirlwind tour through the most common
|
40
|
+
Here is a whirlwind tour through the most common SQL operators. These will probably cover 80% of all interaction with the database.
|
39
41
|
|
40
42
|
First is the 'restriction' operator, `where`:
|
41
43
|
|
@@ -51,6 +53,18 @@ users.project(users[:id])
|
|
51
53
|
# => SELECT users.id FROM users
|
52
54
|
```
|
53
55
|
|
56
|
+
Comparison operators `=`, `!=`, `<`, `>`, `<=`, `>=`, `IN`:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
users.where(users[:age].eq(10)).project(Arel.sql('*')) # => SELECT * FROM "users" WHERE "users"."age" = 10
|
60
|
+
users.where(users[:age].not_eq(10)).project(Arel.sql('*')) # => SELECT * FROM "users" WHERE "users"."age" != 10
|
61
|
+
users.where(users[:age].lt(10)).project(Arel.sql('*')) # => SELECT * FROM "users" WHERE "users"."age" < 10
|
62
|
+
users.where(users[:age].gt(10)).project(Arel.sql('*')) # => SELECT * FROM "users" WHERE "users"."age" > 10
|
63
|
+
users.where(users[:age].lteq(10)).project(Arel.sql('*')) # => SELECT * FROM "users" WHERE "users"."age" <= 10
|
64
|
+
users.where(users[:age].gteq(10)).project(Arel.sql('*')) # => SELECT * FROM "users" WHERE "users"."age" >= 10
|
65
|
+
users.where(users[:age].in([20, 16, 17])).project(Arel.sql('*')) # => SELECT * FROM "users" WHERE "users"."age" IN (20, 16, 17)
|
66
|
+
```
|
67
|
+
|
54
68
|
Joins resemble SQL strongly:
|
55
69
|
|
56
70
|
```ruby
|
@@ -58,6 +72,13 @@ users.join(photos).on(users[:id].eq(photos[:user_id]))
|
|
58
72
|
# => SELECT * FROM users INNER JOIN photos ON users.id = photos.user_id
|
59
73
|
```
|
60
74
|
|
75
|
+
Left Joins
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
users.join(photos, Arel::Nodes::OuterJoin).on(users[:id].eq(photos[:user_id]))
|
79
|
+
# => SELECT FROM users LEFT OUTER JOIN photos ON users.id = photos.user_id
|
80
|
+
```
|
81
|
+
|
61
82
|
What are called `LIMIT` and `OFFSET` in SQL are called `take` and `skip` in Arel:
|
62
83
|
|
63
84
|
```ruby
|
@@ -72,7 +93,7 @@ users.project(users[:name]).group(users[:name])
|
|
72
93
|
# => SELECT users.name FROM users GROUP BY users.name
|
73
94
|
```
|
74
95
|
|
75
|
-
The best property of
|
96
|
+
The best property of arel is its "composability", or closure under all operations. For example, to restrict AND project, just "chain" the method invocations:
|
76
97
|
|
77
98
|
```ruby
|
78
99
|
users \
|
@@ -95,6 +116,23 @@ users.where(users[:name].eq('bob').or(users[:age].lt(25)))
|
|
95
116
|
|
96
117
|
The `AND` operator behaves similarly.
|
97
118
|
|
119
|
+
Aggregate functions `AVG`, `SUM`, `COUNT`, `MIN`, `MAX`, `HAVING`:
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
photos.group(photos[:user_id]).having(photos[:id].count.gt(5)) # => SELECT FROM photos GROUP BY photos.user_id HAVING COUNT(photos.id) > 5
|
123
|
+
users.project(users[:age].sum) # => SELECT SUM(users.age) AS sum_id FROM users
|
124
|
+
users.project(users[:age].average) # => SELECT AVG(users.age) AS avg_id FROM users
|
125
|
+
users.project(users[:age].maximum) # => SELECT MAX(users.age) AS max_id FROM users
|
126
|
+
users.project(users[:age].minimum) # => SELECT MIN(users.age) AS min_id FROM users
|
127
|
+
users.project(users[:age].count) # => SELECT COUNT(users.age) FROM users
|
128
|
+
```
|
129
|
+
|
130
|
+
Aliasing Aggregate Functions:
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
users.project(users[:age].average.as("mean_age")) # => SELECT AVG(users.age) AS mean_age FROM users
|
134
|
+
```
|
135
|
+
|
98
136
|
### The Crazy Features
|
99
137
|
|
100
138
|
The examples above are fairly simple and other libraries match or come close to matching the expressiveness of Arel (e.g., `Sequel` in Ruby).
|
@@ -122,7 +160,7 @@ products.
|
|
122
160
|
|
123
161
|
#### Complex Joins
|
124
162
|
|
125
|
-
Where Arel really shines 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:
|
163
|
+
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:
|
126
164
|
|
127
165
|
```ruby
|
128
166
|
comments = Arel::Table.new(:comments)
|
@@ -134,16 +172,55 @@ And this table has the following attributes:
|
|
134
172
|
# [:id, :body, :parent_id]
|
135
173
|
```
|
136
174
|
|
137
|
-
The `parent_id` column is a foreign key from the `comments` table to itself.
|
175
|
+
The `parent_id` column is a foreign key from the `comments` table to itself.
|
176
|
+
Joining a table to itself requires aliasing in SQL. This aliasing can be handled from Arel as below:
|
138
177
|
|
139
178
|
```ruby
|
140
179
|
replies = comments.alias
|
141
180
|
comments_with_replies = \
|
142
|
-
comments.join(replies).on(replies[:parent_id].eq(comments[:id]))
|
143
|
-
# => SELECT * FROM comments INNER JOIN comments AS comments_2 WHERE comments_2.parent_id = comments.id
|
181
|
+
comments.join(replies).on(replies[:parent_id].eq(comments[:id])).where(comments[:id].eq(1))
|
182
|
+
# => SELECT * FROM comments INNER JOIN comments AS comments_2 WHERE comments_2.parent_id = comments.id AND comments.id = 1
|
183
|
+
```
|
184
|
+
|
185
|
+
This will return the reply for the first comment.
|
186
|
+
|
187
|
+
[Common Table Expresssions(CTE)](https://en.wikipedia.org/wiki/Common_table_expressions#Common_table_expression) support via:
|
188
|
+
|
189
|
+
Create a `CTE`
|
190
|
+
|
191
|
+
```ruby
|
192
|
+
cte_table = Arel::Table.new(:cte_table)
|
193
|
+
composed_cte = Arel::Nodes::As.new(cte_table, photos.where(photos[:created_at].gt(Date.current)))
|
144
194
|
```
|
145
195
|
|
146
|
-
|
196
|
+
Use the created `CTE`:
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
users.
|
200
|
+
join(cte_table).on(users[:id].eq(cte_table[:user_id])).
|
201
|
+
project(users[:id], cte_table[:click].sum).
|
202
|
+
with(composed_cte)
|
203
|
+
|
204
|
+
# => WITH cte_table AS (SELECT FROM photos WHERE photos.created_at > '2014-05-02') SELECT users.id, SUM(cte_table.click) AS sum_id FROM users INNER JOIN cte_table ON users.id = cte_table.user_id
|
205
|
+
```
|
206
|
+
|
207
|
+
When your query is too complex for `Arel`, you can use `Arel::SqlLiteral`:
|
208
|
+
|
209
|
+
```ruby
|
210
|
+
photo_clicks = Arel::Nodes::SqlLiteral.new(<<-SQL
|
211
|
+
CASE WHEN condition1 THEN calculation1
|
212
|
+
WHEN condition2 THEN calculation2
|
213
|
+
WHEN condition3 THEN calculation3
|
214
|
+
ELSE default_calculation END
|
215
|
+
SQL
|
216
|
+
)
|
217
|
+
photos.project(photo_clicks.as("photo_clicks"))
|
218
|
+
# => SELECT CASE WHEN condition1 THEN calculation1
|
219
|
+
WHEN condition2 THEN calculation2
|
220
|
+
WHEN condition3 THEN calculation3
|
221
|
+
ELSE default_calculation END
|
222
|
+
FROM "photos"
|
223
|
+
```
|
147
224
|
|
148
225
|
### License
|
149
226
|
|
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ Hoe.plugin :bundler # `gem install hoe-bundler`
|
|
10
10
|
|
11
11
|
Hoe.spec 'arel' do
|
12
12
|
developer('Aaron Patterson', 'aaron@tenderlovemaking.com')
|
13
|
-
developer('Bryan
|
13
|
+
developer('Bryan Helmkamp', 'bryan@brynary.com')
|
14
14
|
developer('Emilio Tagua', 'miloops@gmail.com')
|
15
15
|
developer('Nick Kallen', 'nick@example.org') # FIXME: need Nick's email
|
16
16
|
|
data/arel.gemspec
CHANGED
@@ -1,41 +1,40 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: arel
|
2
|
+
# stub: arel 6.0.0.beta1.20140817224534 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "arel"
|
6
|
-
s.version = "
|
6
|
+
s.version = "6.0.0.beta1.20140817224534"
|
7
7
|
|
8
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib"]
|
10
|
-
s.authors = ["Aaron Patterson", "Bryan
|
11
|
-
s.date = "2014-
|
12
|
-
s.description = "Arel is a SQL AST manager for Ruby. It\n\n1. Simplifies the generation of complex SQL queries\n2. Adapts to various RDBMSes\n\nIt is intended to be a framework framework; that is, you can build your own ORM\nwith it, focusing on innovative object and collection modeling as opposed to\ndatabase compatibility and query generation."
|
10
|
+
s.authors = ["Aaron Patterson", "Bryan Helmkamp", "Emilio Tagua", "Nick Kallen"]
|
11
|
+
s.date = "2014-08-18"
|
12
|
+
s.description = "Arel Really Exasperates Logicians\n\nArel is a SQL AST manager for Ruby. It\n\n1. Simplifies the generation of complex SQL queries\n2. Adapts to various RDBMSes\n\nIt is intended to be a framework framework; that is, you can build your own ORM\nwith it, focusing on innovative object and collection modeling as opposed to\ndatabase compatibility and query generation."
|
13
13
|
s.email = ["aaron@tenderlovemaking.com", "bryan@brynary.com", "miloops@gmail.com", "nick@example.org"]
|
14
14
|
s.extra_rdoc_files = ["History.txt", "MIT-LICENSE.txt", "Manifest.txt", "README.markdown"]
|
15
|
-
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/
|
15
|
+
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/collectors/bind.rb", "lib/arel/collectors/plain_string.rb", "lib/arel/collectors/sql_string.rb", "lib/arel/compatibility/wheres.rb", "lib/arel/crud.rb", "lib/arel/delete_manager.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/full_outer_join.rb", "lib/arel/nodes/function.rb", "lib/arel/nodes/grouping.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/outer_join.rb", "lib/arel/nodes/over.rb", "lib/arel/nodes/right_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/window.rb", "lib/arel/nodes/with.rb", "lib/arel/order_predications.rb", "lib/arel/predications.rb", "lib/arel/select_manager.rb", "lib/arel/table.rb", "lib/arel/tree_manager.rb", "lib/arel/update_manager.rb", "lib/arel/visitors.rb", "lib/arel/visitors/bind_substitute.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/mssql.rb", "lib/arel/visitors/mysql.rb", "lib/arel/visitors/oracle.rb", "lib/arel/visitors/postgresql.rb", "lib/arel/visitors/reduce.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/collectors/test_bind_collector.rb", "test/collectors/test_sql_string.rb", "test/helper.rb", "test/nodes/test_and.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_distinct.rb", "test/nodes/test_equality.rb", "test/nodes/test_extract.rb", "test/nodes/test_false.rb", "test/nodes/test_grouping.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_table_alias.rb", "test/nodes/test_true.rb", "test/nodes/test_update_statement.rb", "test/nodes/test_window.rb", "test/support/fake_record.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_dispatch_contamination.rb", "test/visitors/test_dot.rb", "test/visitors/test_ibm_db.rb", "test/visitors/test_informix.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"]
|
16
16
|
s.homepage = "http://github.com/rails/arel"
|
17
17
|
s.licenses = ["MIT"]
|
18
18
|
s.rdoc_options = ["--main", "README.markdown"]
|
19
|
-
s.rubyforge_project = "arel"
|
20
19
|
s.rubygems_version = "2.2.2"
|
21
|
-
s.summary = "Arel is a SQL AST manager for Ruby"
|
22
|
-
s.test_files = ["test/attributes/test_attribute.rb", "test/nodes/test_and.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_distinct.rb", "test/nodes/test_equality.rb", "test/nodes/test_extract.rb", "test/nodes/test_false.rb", "test/nodes/test_grouping.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_table_alias.rb", "test/nodes/test_true.rb", "test/nodes/test_update_statement.rb", "test/nodes/test_window.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_dispatch_contamination.rb", "test/visitors/test_dot.rb", "test/visitors/test_ibm_db.rb", "test/visitors/test_informix.rb", "test/visitors/
|
20
|
+
s.summary = "Arel Really Exasperates Logicians Arel is a SQL AST manager for Ruby"
|
21
|
+
s.test_files = ["test/attributes/test_attribute.rb", "test/collectors/test_bind_collector.rb", "test/collectors/test_sql_string.rb", "test/nodes/test_and.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_distinct.rb", "test/nodes/test_equality.rb", "test/nodes/test_extract.rb", "test/nodes/test_false.rb", "test/nodes/test_grouping.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_table_alias.rb", "test/nodes/test_true.rb", "test/nodes/test_update_statement.rb", "test/nodes/test_window.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_dispatch_contamination.rb", "test/visitors/test_dot.rb", "test/visitors/test_ibm_db.rb", "test/visitors/test_informix.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"]
|
23
22
|
|
24
23
|
if s.respond_to? :specification_version then
|
25
24
|
s.specification_version = 4
|
26
25
|
|
27
26
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
28
|
-
s.add_development_dependency(%q<minitest>, ["~> 5.
|
27
|
+
s.add_development_dependency(%q<minitest>, ["~> 5.4"])
|
29
28
|
s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
|
30
|
-
s.add_development_dependency(%q<hoe>, ["~> 3.
|
29
|
+
s.add_development_dependency(%q<hoe>, ["~> 3.12"])
|
31
30
|
else
|
32
|
-
s.add_dependency(%q<minitest>, ["~> 5.
|
31
|
+
s.add_dependency(%q<minitest>, ["~> 5.4"])
|
33
32
|
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
34
|
-
s.add_dependency(%q<hoe>, ["~> 3.
|
33
|
+
s.add_dependency(%q<hoe>, ["~> 3.12"])
|
35
34
|
end
|
36
35
|
else
|
37
|
-
s.add_dependency(%q<minitest>, ["~> 5.
|
36
|
+
s.add_dependency(%q<minitest>, ["~> 5.4"])
|
38
37
|
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
39
|
-
s.add_dependency(%q<hoe>, ["~> 3.
|
38
|
+
s.add_dependency(%q<hoe>, ["~> 3.12"])
|
40
39
|
end
|
41
40
|
end
|
data/lib/arel.rb
CHANGED
@@ -11,10 +11,6 @@ require 'arel/table'
|
|
11
11
|
require 'arel/attributes'
|
12
12
|
require 'arel/compatibility/wheres'
|
13
13
|
|
14
|
-
#### these are deprecated
|
15
|
-
require 'arel/expression'
|
16
|
-
####
|
17
|
-
|
18
14
|
require 'arel/visitors'
|
19
15
|
|
20
16
|
require 'arel/tree_manager'
|
@@ -24,15 +20,8 @@ require 'arel/update_manager'
|
|
24
20
|
require 'arel/delete_manager'
|
25
21
|
require 'arel/nodes'
|
26
22
|
|
27
|
-
|
28
|
-
#### these are deprecated
|
29
|
-
require 'arel/deprecated'
|
30
|
-
require 'arel/sql/engine'
|
31
|
-
require 'arel/sql_literal'
|
32
|
-
####
|
33
|
-
|
34
23
|
module Arel
|
35
|
-
VERSION = '
|
24
|
+
VERSION = '6.0.0.beta1'
|
36
25
|
|
37
26
|
def self.sql raw_sql
|
38
27
|
Arel::Nodes::SqlLiteral.new raw_sql
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Arel
|
2
|
+
module Collectors
|
3
|
+
class Bind
|
4
|
+
def initialize
|
5
|
+
@parts = []
|
6
|
+
end
|
7
|
+
|
8
|
+
def << str
|
9
|
+
@parts << str
|
10
|
+
self
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_bind bind
|
14
|
+
@parts << bind
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def value; @parts; end
|
19
|
+
|
20
|
+
def substitute_binds bvs
|
21
|
+
bvs = bvs.dup
|
22
|
+
@parts.map do |val|
|
23
|
+
if Arel::Nodes::BindParam === val
|
24
|
+
bvs.shift
|
25
|
+
else
|
26
|
+
val
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def compile bvs
|
32
|
+
substitute_binds(bvs).join
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|