arel 4.0.0 → 4.0.1
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 +7 -0
- data/History.txt +15 -3
- data/Manifest.txt +1 -0
- data/README.markdown +71 -34
- data/Rakefile +1 -0
- data/arel.gemspec +16 -15
- data/lib/arel.rb +1 -1
- data/lib/arel/nodes/and.rb +1 -0
- data/lib/arel/nodes/binary.rb +1 -0
- data/lib/arel/nodes/function.rb +1 -0
- data/lib/arel/nodes/insert_statement.rb +1 -0
- data/lib/arel/nodes/node.rb +10 -0
- data/lib/arel/nodes/select_core.rb +1 -0
- data/lib/arel/nodes/select_statement.rb +1 -0
- data/lib/arel/nodes/unary.rb +1 -0
- data/lib/arel/table.rb +4 -1
- data/lib/arel/visitors/bind_visitor.rb +4 -4
- data/lib/arel/visitors/depth_first.rb +56 -56
- data/lib/arel/visitors/dot.rb +75 -75
- data/lib/arel/visitors/ibm_db.rb +2 -2
- data/lib/arel/visitors/informix.rb +17 -17
- data/lib/arel/visitors/join_sql.rb +2 -2
- data/lib/arel/visitors/mssql.rb +12 -12
- data/lib/arel/visitors/mysql.rb +15 -15
- data/lib/arel/visitors/oracle.rb +19 -19
- data/lib/arel/visitors/order_clauses.rb +2 -2
- data/lib/arel/visitors/postgresql.rb +6 -6
- data/lib/arel/visitors/sqlite.rb +2 -2
- data/lib/arel/visitors/to_sql.rb +172 -168
- data/lib/arel/visitors/visitor.rb +8 -5
- data/lib/arel/visitors/where_sql.rb +2 -2
- data/test/test_update_manager.rb +1 -0
- data/test/visitors/test_dispatch_contamination.rb +22 -0
- data/test/visitors/test_oracle.rb +2 -1
- data/test/visitors/test_to_sql.rb +1 -1
- metadata +18 -27
@@ -7,16 +7,19 @@ module Arel
|
|
7
7
|
|
8
8
|
private
|
9
9
|
|
10
|
-
DISPATCH = Hash.new do |hash,
|
11
|
-
hash[
|
10
|
+
DISPATCH = Hash.new do |hash, visitor_class|
|
11
|
+
hash[visitor_class] =
|
12
|
+
Hash.new do |hash, node_class|
|
13
|
+
hash[node_class] = "visit_#{(node_class.name || '').gsub('::', '_')}"
|
14
|
+
end
|
12
15
|
end
|
13
16
|
|
14
17
|
def dispatch
|
15
|
-
DISPATCH
|
18
|
+
DISPATCH[self.class]
|
16
19
|
end
|
17
20
|
|
18
|
-
def visit object
|
19
|
-
send dispatch[object.class], object
|
21
|
+
def visit object, attribute = nil
|
22
|
+
send dispatch[object.class], object, attribute
|
20
23
|
rescue NoMethodError => e
|
21
24
|
raise e if respond_to?(dispatch[object.class], true)
|
22
25
|
superklass = object.class.ancestors.find { |klass|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Arel
|
2
2
|
module Visitors
|
3
3
|
class WhereSql < Arel::Visitors::ToSql
|
4
|
-
def visit_Arel_Nodes_SelectCore o
|
5
|
-
"WHERE #{o.wheres.map { |x| visit x }.join ' AND ' }"
|
4
|
+
def visit_Arel_Nodes_SelectCore o, a
|
5
|
+
"WHERE #{o.wheres.map { |x| visit x, a }.join ' AND ' }"
|
6
6
|
end
|
7
7
|
end
|
8
8
|
end
|
data/test/test_update_manager.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module Arel
|
4
|
+
module Visitors
|
5
|
+
describe 'avoiding contamination between visitor dispatch tables' do
|
6
|
+
before do
|
7
|
+
@connection = Table.engine.connection
|
8
|
+
@table = Table.new(:users)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'dispatches properly after failing upwards' do
|
12
|
+
node = Nodes::Union.new(Nodes::True.new, Nodes::False.new)
|
13
|
+
assert_equal "( TRUE UNION FALSE )", node.to_sql
|
14
|
+
|
15
|
+
node.first # from Nodes::Node's Enumerable mixin
|
16
|
+
|
17
|
+
assert_equal "( TRUE UNION FALSE )", node.to_sql
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -85,7 +85,8 @@ module Arel
|
|
85
85
|
|
86
86
|
it 'creates a subquery when there is DISTINCT' do
|
87
87
|
stmt = Nodes::SelectStatement.new
|
88
|
-
stmt.cores.first.
|
88
|
+
stmt.cores.first.set_quantifier = Arel::Nodes::Distinct.new
|
89
|
+
stmt.cores.first.projections << Nodes::SqlLiteral.new('id')
|
89
90
|
stmt.limit = Arel::Nodes::Limit.new(10)
|
90
91
|
sql = @visitor.accept stmt
|
91
92
|
sql.must_be_like %{
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
5
|
-
prerelease:
|
4
|
+
version: 4.0.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Aaron Patterson
|
@@ -12,28 +11,25 @@ authors:
|
|
12
11
|
autorequire:
|
13
12
|
bindir: bin
|
14
13
|
cert_chain: []
|
15
|
-
date: 2013-
|
14
|
+
date: 2013-10-22 00:00:00.000000000 Z
|
16
15
|
dependencies:
|
17
16
|
- !ruby/object:Gem::Dependency
|
18
17
|
name: minitest
|
19
18
|
requirement: !ruby/object:Gem::Requirement
|
20
|
-
none: false
|
21
19
|
requirements:
|
22
20
|
- - ~>
|
23
21
|
- !ruby/object:Gem::Version
|
24
|
-
version: '
|
22
|
+
version: '5.0'
|
25
23
|
type: :development
|
26
24
|
prerelease: false
|
27
25
|
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
26
|
requirements:
|
30
27
|
- - ~>
|
31
28
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
29
|
+
version: '5.0'
|
33
30
|
- !ruby/object:Gem::Dependency
|
34
31
|
name: rdoc
|
35
32
|
requirement: !ruby/object:Gem::Requirement
|
36
|
-
none: false
|
37
33
|
requirements:
|
38
34
|
- - ~>
|
39
35
|
- !ruby/object:Gem::Version
|
@@ -41,7 +37,6 @@ dependencies:
|
|
41
37
|
type: :development
|
42
38
|
prerelease: false
|
43
39
|
version_requirements: !ruby/object:Gem::Requirement
|
44
|
-
none: false
|
45
40
|
requirements:
|
46
41
|
- - ~>
|
47
42
|
- !ruby/object:Gem::Version
|
@@ -49,32 +44,26 @@ dependencies:
|
|
49
44
|
- !ruby/object:Gem::Dependency
|
50
45
|
name: hoe
|
51
46
|
requirement: !ruby/object:Gem::Requirement
|
52
|
-
none: false
|
53
47
|
requirements:
|
54
48
|
- - ~>
|
55
49
|
- !ruby/object:Gem::Version
|
56
|
-
version: '3.
|
50
|
+
version: '3.7'
|
57
51
|
type: :development
|
58
52
|
prerelease: false
|
59
53
|
version_requirements: !ruby/object:Gem::Requirement
|
60
|
-
none: false
|
61
54
|
requirements:
|
62
55
|
- - ~>
|
63
56
|
- !ruby/object:Gem::Version
|
64
|
-
version: '3.
|
65
|
-
description:
|
66
|
-
|
57
|
+
version: '3.7'
|
58
|
+
description: |-
|
59
|
+
Arel is a SQL AST manager for Ruby. It
|
67
60
|
|
68
61
|
1. Simplifies the generation of complex SQL queries
|
69
|
-
|
70
62
|
2. Adapts to various RDBMS systems
|
71
63
|
|
72
|
-
|
73
64
|
It is intended to be a framework framework; that is, you can build your own ORM
|
74
|
-
|
75
65
|
with it, focusing on innovative object and collection modeling as opposed to
|
76
|
-
|
77
|
-
database compatibility and query generation.'
|
66
|
+
database compatibility and query generation.
|
78
67
|
email:
|
79
68
|
- aaron@tenderlovemaking.com
|
80
69
|
- bryan@brynary.com
|
@@ -211,6 +200,7 @@ files:
|
|
211
200
|
- test/test_update_manager.rb
|
212
201
|
- test/visitors/test_bind_visitor.rb
|
213
202
|
- test/visitors/test_depth_first.rb
|
203
|
+
- test/visitors/test_dispatch_contamination.rb
|
214
204
|
- test/visitors/test_dot.rb
|
215
205
|
- test/visitors/test_ibm_db.rb
|
216
206
|
- test/visitors/test_informix.rb
|
@@ -222,7 +212,9 @@ files:
|
|
222
212
|
- test/visitors/test_sqlite.rb
|
223
213
|
- test/visitors/test_to_sql.rb
|
224
214
|
homepage: http://github.com/rails/arel
|
225
|
-
licenses:
|
215
|
+
licenses:
|
216
|
+
- MIT
|
217
|
+
metadata: {}
|
226
218
|
post_install_message:
|
227
219
|
rdoc_options:
|
228
220
|
- --main
|
@@ -230,22 +222,20 @@ rdoc_options:
|
|
230
222
|
require_paths:
|
231
223
|
- lib
|
232
224
|
required_ruby_version: !ruby/object:Gem::Requirement
|
233
|
-
none: false
|
234
225
|
requirements:
|
235
|
-
- -
|
226
|
+
- - '>='
|
236
227
|
- !ruby/object:Gem::Version
|
237
228
|
version: '0'
|
238
229
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
239
|
-
none: false
|
240
230
|
requirements:
|
241
|
-
- -
|
231
|
+
- - '>='
|
242
232
|
- !ruby/object:Gem::Version
|
243
233
|
version: '0'
|
244
234
|
requirements: []
|
245
235
|
rubyforge_project: arel
|
246
|
-
rubygems_version:
|
236
|
+
rubygems_version: 2.0.6
|
247
237
|
signing_key:
|
248
|
-
specification_version:
|
238
|
+
specification_version: 4
|
249
239
|
summary: Arel is a SQL AST manager for Ruby
|
250
240
|
test_files:
|
251
241
|
- test/attributes/test_attribute.rb
|
@@ -287,6 +277,7 @@ test_files:
|
|
287
277
|
- test/test_update_manager.rb
|
288
278
|
- test/visitors/test_bind_visitor.rb
|
289
279
|
- test/visitors/test_depth_first.rb
|
280
|
+
- test/visitors/test_dispatch_contamination.rb
|
290
281
|
- test/visitors/test_dot.rb
|
291
282
|
- test/visitors/test_ibm_db.rb
|
292
283
|
- test/visitors/test_informix.rb
|