arel 4.0.1 → 4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/History.txt +7 -0
- data/arel.gemspec +11 -10
- data/lib/arel.rb +1 -1
- data/lib/arel/nodes/sql_literal.rb +4 -0
- data/lib/arel/visitors/postgresql.rb +2 -0
- data/lib/arel/visitors/visitor.rb +2 -2
- data/test/nodes/test_sql_literal.rb +8 -0
- data/test/visitors/test_postgres.rb +36 -0
- data/test/visitors/test_to_sql.rb +34 -0
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe1827bf9b3fb8d0df377a874b604c6d1fbb4387
|
4
|
+
data.tar.gz: 050b51b492c74c09be3aa3f4a58487ef3150c57b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 200b67f47b08b79e6b514035398fd8f00d810e786af0de57862ee68ec4ff228f68b036419273add78450df7c18f6da4b54b68e6b78eeacbb98575c40d426d2be
|
7
|
+
data.tar.gz: 692a06c47c099852541d12c6499ef2c9bbe0f943fc5f2023f6523e6a819c14d43e7add74e834b9aa0290a17156bc4bf38ba32d043daf6248e20765664104141c
|
data/.travis.yml
CHANGED
data/History.txt
CHANGED
data/arel.gemspec
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
# stub: arel 4.0.2.20140205180311 ruby lib
|
2
3
|
|
3
4
|
Gem::Specification.new do |s|
|
4
5
|
s.name = "arel"
|
5
|
-
s.version = "4.0.
|
6
|
+
s.version = "4.0.2.20140205180311"
|
6
7
|
|
7
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
|
+
s.require_paths = ["lib"]
|
8
10
|
s.authors = ["Aaron Patterson", "Bryan Halmkamp", "Emilio Tagua", "Nick Kallen"]
|
9
|
-
s.date = "
|
11
|
+
s.date = "2014-02-05"
|
10
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 RDBMS systems\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."
|
11
13
|
s.email = ["aaron@tenderlovemaking.com", "bryan@brynary.com", "miloops@gmail.com", "nick@example.org"]
|
12
14
|
s.extra_rdoc_files = ["History.txt", "MIT-LICENSE.txt", "Manifest.txt", "README.markdown"]
|
@@ -14,9 +16,8 @@ Gem::Specification.new do |s|
|
|
14
16
|
s.homepage = "http://github.com/rails/arel"
|
15
17
|
s.licenses = ["MIT"]
|
16
18
|
s.rdoc_options = ["--main", "README.markdown"]
|
17
|
-
s.require_paths = ["lib"]
|
18
19
|
s.rubyforge_project = "arel"
|
19
|
-
s.rubygems_version = "2.0
|
20
|
+
s.rubygems_version = "2.2.0"
|
20
21
|
s.summary = "Arel is a SQL AST manager for Ruby"
|
21
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_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_dispatch_contamination.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"]
|
22
23
|
|
@@ -24,17 +25,17 @@ Gem::Specification.new do |s|
|
|
24
25
|
s.specification_version = 4
|
25
26
|
|
26
27
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
27
|
-
s.add_development_dependency(%q<minitest>, ["~> 5.
|
28
|
+
s.add_development_dependency(%q<minitest>, ["~> 5.2"])
|
28
29
|
s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
|
29
|
-
s.add_development_dependency(%q<hoe>, ["~> 3.
|
30
|
+
s.add_development_dependency(%q<hoe>, ["~> 3.8"])
|
30
31
|
else
|
31
|
-
s.add_dependency(%q<minitest>, ["~> 5.
|
32
|
+
s.add_dependency(%q<minitest>, ["~> 5.2"])
|
32
33
|
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
33
|
-
s.add_dependency(%q<hoe>, ["~> 3.
|
34
|
+
s.add_dependency(%q<hoe>, ["~> 3.8"])
|
34
35
|
end
|
35
36
|
else
|
36
|
-
s.add_dependency(%q<minitest>, ["~> 5.
|
37
|
+
s.add_dependency(%q<minitest>, ["~> 5.2"])
|
37
38
|
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
38
|
-
s.add_dependency(%q<hoe>, ["~> 3.
|
39
|
+
s.add_dependency(%q<hoe>, ["~> 3.8"])
|
39
40
|
end
|
40
41
|
end
|
data/lib/arel.rb
CHANGED
@@ -4,10 +4,12 @@ module Arel
|
|
4
4
|
private
|
5
5
|
|
6
6
|
def visit_Arel_Nodes_Matches o, a
|
7
|
+
a = o.left if Arel::Attributes::Attribute === o.left
|
7
8
|
"#{visit o.left, a} ILIKE #{visit o.right, a}"
|
8
9
|
end
|
9
10
|
|
10
11
|
def visit_Arel_Nodes_DoesNotMatch o, a
|
12
|
+
a = o.left if Arel::Attributes::Attribute === o.left
|
11
13
|
"#{visit o.left, a} NOT ILIKE #{visit o.right, a}"
|
12
14
|
end
|
13
15
|
|
@@ -9,8 +9,8 @@ module Arel
|
|
9
9
|
|
10
10
|
DISPATCH = Hash.new do |hash, visitor_class|
|
11
11
|
hash[visitor_class] =
|
12
|
-
Hash.new do |
|
13
|
-
|
12
|
+
Hash.new do |method_hash, node_class|
|
13
|
+
method_hash[node_class] = "visit_#{(node_class.name || '').gsub('::', '_')}"
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'helper'
|
2
|
+
require 'yaml'
|
2
3
|
|
3
4
|
module Arel
|
4
5
|
module Nodes
|
@@ -56,6 +57,13 @@ module Arel
|
|
56
57
|
@visitor.accept(node).must_be_like %{ (foo = 1 AND foo = 2) }
|
57
58
|
end
|
58
59
|
end
|
60
|
+
|
61
|
+
describe 'serialization' do
|
62
|
+
it 'serializes into YAML' do
|
63
|
+
yaml_literal = SqlLiteral.new('foo').to_yaml
|
64
|
+
assert_equal('foo', YAML.load(yaml_literal))
|
65
|
+
end
|
66
|
+
end
|
59
67
|
end
|
60
68
|
end
|
61
69
|
end
|
@@ -5,6 +5,8 @@ module Arel
|
|
5
5
|
describe 'the postgres visitor' do
|
6
6
|
before do
|
7
7
|
@visitor = PostgreSQL.new Table.engine.connection
|
8
|
+
@table = Table.new(:users)
|
9
|
+
@attr = @table[:id]
|
8
10
|
end
|
9
11
|
|
10
12
|
describe 'locking' do
|
@@ -43,6 +45,40 @@ module Arel
|
|
43
45
|
core.set_quantifier = Arel::Nodes::Distinct.new
|
44
46
|
assert_equal 'SELECT DISTINCT', @visitor.accept(core)
|
45
47
|
end
|
48
|
+
|
49
|
+
describe "Nodes::Matches" do
|
50
|
+
it "should know how to visit" do
|
51
|
+
node = @table[:name].matches('foo%')
|
52
|
+
@visitor.accept(node).must_be_like %{
|
53
|
+
"users"."name" ILIKE 'foo%'
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'can handle subqueries' do
|
58
|
+
subquery = @table.project(:id).where(@table[:name].matches('foo%'))
|
59
|
+
node = @attr.in subquery
|
60
|
+
@visitor.accept(node).must_be_like %{
|
61
|
+
"users"."id" IN (SELECT id FROM "users" WHERE "users"."name" ILIKE 'foo%')
|
62
|
+
}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "Nodes::DoesNotMatch" do
|
67
|
+
it "should know how to visit" do
|
68
|
+
node = @table[:name].does_not_match('foo%')
|
69
|
+
@visitor.accept(node).must_be_like %{
|
70
|
+
"users"."name" NOT ILIKE 'foo%'
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'can handle subqueries' do
|
75
|
+
subquery = @table.project(:id).where(@table[:name].does_not_match('foo%'))
|
76
|
+
node = @attr.in subquery
|
77
|
+
@visitor.accept(node).must_be_like %{
|
78
|
+
"users"."id" IN (SELECT id FROM "users" WHERE "users"."name" NOT ILIKE 'foo%')
|
79
|
+
}
|
80
|
+
end
|
81
|
+
end
|
46
82
|
end
|
47
83
|
end
|
48
84
|
end
|
@@ -194,6 +194,40 @@ module Arel
|
|
194
194
|
@visitor.accept(test).must_be_like %{ "users"."bool" = 't' }
|
195
195
|
end
|
196
196
|
|
197
|
+
describe "Nodes::Matches" do
|
198
|
+
it "should know how to visit" do
|
199
|
+
node = @table[:name].matches('foo%')
|
200
|
+
@visitor.accept(node).must_be_like %{
|
201
|
+
"users"."name" LIKE 'foo%'
|
202
|
+
}
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'can handle subqueries' do
|
206
|
+
subquery = @table.project(:id).where(@table[:name].matches('foo%'))
|
207
|
+
node = @attr.in subquery
|
208
|
+
@visitor.accept(node).must_be_like %{
|
209
|
+
"users"."id" IN (SELECT id FROM "users" WHERE "users"."name" LIKE 'foo%')
|
210
|
+
}
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
describe "Nodes::DoesNotMatch" do
|
215
|
+
it "should know how to visit" do
|
216
|
+
node = @table[:name].does_not_match('foo%')
|
217
|
+
@visitor.accept(node).must_be_like %{
|
218
|
+
"users"."name" NOT LIKE 'foo%'
|
219
|
+
}
|
220
|
+
end
|
221
|
+
|
222
|
+
it 'can handle subqueries' do
|
223
|
+
subquery = @table.project(:id).where(@table[:name].does_not_match('foo%'))
|
224
|
+
node = @attr.in subquery
|
225
|
+
@visitor.accept(node).must_be_like %{
|
226
|
+
"users"."id" IN (SELECT id FROM "users" WHERE "users"."name" NOT LIKE 'foo%')
|
227
|
+
}
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
197
231
|
describe "Nodes::Ordering" do
|
198
232
|
it "should know how to visit" do
|
199
233
|
node = @attr.desc
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
@@ -11,50 +11,50 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2014-02-05 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: minitest
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|
19
19
|
requirements:
|
20
|
-
- - ~>
|
20
|
+
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '5.
|
22
|
+
version: '5.2'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - ~>
|
27
|
+
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '5.
|
29
|
+
version: '5.2'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rdoc
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
|
-
- - ~>
|
34
|
+
- - "~>"
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: '4.0'
|
37
37
|
type: :development
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- - ~>
|
41
|
+
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '4.0'
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: hoe
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
|
-
- - ~>
|
48
|
+
- - "~>"
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version: '3.
|
50
|
+
version: '3.8'
|
51
51
|
type: :development
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
|
-
- - ~>
|
55
|
+
- - "~>"
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: '3.
|
57
|
+
version: '3.8'
|
58
58
|
description: |-
|
59
59
|
Arel is a SQL AST manager for Ruby. It
|
60
60
|
|
@@ -77,9 +77,9 @@ extra_rdoc_files:
|
|
77
77
|
- Manifest.txt
|
78
78
|
- README.markdown
|
79
79
|
files:
|
80
|
-
- .autotest
|
81
|
-
- .gemtest
|
82
|
-
- .travis.yml
|
80
|
+
- ".autotest"
|
81
|
+
- ".gemtest"
|
82
|
+
- ".travis.yml"
|
83
83
|
- Gemfile
|
84
84
|
- History.txt
|
85
85
|
- MIT-LICENSE.txt
|
@@ -217,23 +217,23 @@ licenses:
|
|
217
217
|
metadata: {}
|
218
218
|
post_install_message:
|
219
219
|
rdoc_options:
|
220
|
-
- --main
|
220
|
+
- "--main"
|
221
221
|
- README.markdown
|
222
222
|
require_paths:
|
223
223
|
- lib
|
224
224
|
required_ruby_version: !ruby/object:Gem::Requirement
|
225
225
|
requirements:
|
226
|
-
- -
|
226
|
+
- - ">="
|
227
227
|
- !ruby/object:Gem::Version
|
228
228
|
version: '0'
|
229
229
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
230
230
|
requirements:
|
231
|
-
- -
|
231
|
+
- - ">="
|
232
232
|
- !ruby/object:Gem::Version
|
233
233
|
version: '0'
|
234
234
|
requirements: []
|
235
235
|
rubyforge_project: arel
|
236
|
-
rubygems_version: 2.0
|
236
|
+
rubygems_version: 2.2.0
|
237
237
|
signing_key:
|
238
238
|
specification_version: 4
|
239
239
|
summary: Arel is a SQL AST manager for Ruby
|