arel 2.1.3 → 2.1.4
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/History.txt +7 -0
- data/arel.gemspec +18 -17
- data/lib/arel.rb +1 -1
- data/lib/arel/visitors/depth_first.rb +2 -0
- data/lib/arel/visitors/mysql.rb +22 -0
- data/test/test_select_manager.rb +9 -0
- data/test/visitors/test_mysql.rb +10 -0
- metadata +22 -14
data/History.txt
CHANGED
data/arel.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{arel}
|
5
|
-
s.version = "2.1.
|
5
|
+
s.version = "2.1.4.20110725155854"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = [
|
9
|
-
s.date = %q{2011-
|
8
|
+
s.authors = ["Aaron Patterson", "Bryan Halmkamp", "Emilio Tagua", "Nick Kallen"]
|
9
|
+
s.date = %q{2011-07-25}
|
10
10
|
s.description = %q{Arel is a SQL AST manager for Ruby. It
|
11
11
|
|
12
12
|
1. Simplifies the generation complex of SQL queries
|
@@ -15,29 +15,30 @@ Gem::Specification.new do |s|
|
|
15
15
|
It is intended to be a framework framework; that is, you can build your own ORM
|
16
16
|
with it, focusing on innovative object and collection modeling as opposed to
|
17
17
|
database compatibility and query generation.}
|
18
|
-
s.email = [
|
19
|
-
s.extra_rdoc_files = [
|
20
|
-
s.files = [
|
18
|
+
s.email = ["aaron@tenderlovemaking.com", "bryan@brynary.com", "miloops@gmail.com", "nick@example.org"]
|
19
|
+
s.extra_rdoc_files = ["History.txt", "MIT-LICENSE.txt", "Manifest.txt", "README.markdown"]
|
20
|
+
s.files = [".autotest", ".gemtest", "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/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/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"]
|
21
21
|
s.homepage = %q{http://github.com/rails/arel}
|
22
|
-
s.rdoc_options = [
|
23
|
-
s.require_paths = [
|
22
|
+
s.rdoc_options = ["--main", "README.markdown"]
|
23
|
+
s.require_paths = ["lib"]
|
24
24
|
s.rubyforge_project = %q{arel}
|
25
|
-
s.rubygems_version = %q{1.
|
25
|
+
s.rubygems_version = %q{1.3.6}
|
26
26
|
s.summary = %q{Arel is a SQL AST manager for Ruby}
|
27
|
-
s.test_files = [
|
27
|
+
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"]
|
28
28
|
|
29
29
|
if s.respond_to? :specification_version then
|
30
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
30
31
|
s.specification_version = 3
|
31
32
|
|
32
|
-
if Gem::Version.new(Gem::
|
33
|
-
s.add_development_dependency(%q<minitest>, ["
|
34
|
-
s.add_development_dependency(%q<hoe>, ["
|
33
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
34
|
+
s.add_development_dependency(%q<minitest>, ["~> 2.3"])
|
35
|
+
s.add_development_dependency(%q<hoe>, ["~> 2.9"])
|
35
36
|
else
|
36
|
-
s.add_dependency(%q<minitest>, ["
|
37
|
-
s.add_dependency(%q<hoe>, ["
|
37
|
+
s.add_dependency(%q<minitest>, ["~> 2.3"])
|
38
|
+
s.add_dependency(%q<hoe>, ["~> 2.9"])
|
38
39
|
end
|
39
40
|
else
|
40
|
-
s.add_dependency(%q<minitest>, ["
|
41
|
-
s.add_dependency(%q<hoe>, ["
|
41
|
+
s.add_dependency(%q<minitest>, ["~> 2.3"])
|
42
|
+
s.add_dependency(%q<hoe>, ["~> 2.9"])
|
42
43
|
end
|
43
44
|
end
|
data/lib/arel.rb
CHANGED
@@ -23,6 +23,8 @@ module Arel
|
|
23
23
|
alias :visit_Arel_Nodes_Offset :unary
|
24
24
|
alias :visit_Arel_Nodes_On :unary
|
25
25
|
alias :visit_Arel_Nodes_Ordering :unary
|
26
|
+
alias :visit_Arel_Nodes_Ascending :unary
|
27
|
+
alias :visit_Arel_Nodes_Descending :unary
|
26
28
|
alias :visit_Arel_Nodes_Top :unary
|
27
29
|
alias :visit_Arel_Nodes_UnqualifiedColumn :unary
|
28
30
|
|
data/lib/arel/visitors/mysql.rb
CHANGED
@@ -2,6 +2,28 @@ module Arel
|
|
2
2
|
module Visitors
|
3
3
|
class MySQL < Arel::Visitors::ToSql
|
4
4
|
private
|
5
|
+
def visit_Arel_Nodes_Union o, suppress_parens = false
|
6
|
+
left_result = case o.left
|
7
|
+
when Arel::Nodes::Union
|
8
|
+
visit_Arel_Nodes_Union o.left, true
|
9
|
+
else
|
10
|
+
visit o.left
|
11
|
+
end
|
12
|
+
|
13
|
+
right_result = case o.right
|
14
|
+
when Arel::Nodes::Union
|
15
|
+
visit_Arel_Nodes_Union o.right, true
|
16
|
+
else
|
17
|
+
visit o.right
|
18
|
+
end
|
19
|
+
|
20
|
+
if suppress_parens
|
21
|
+
"#{left_result} UNION #{right_result}"
|
22
|
+
else
|
23
|
+
"( #{left_result} UNION #{right_result} )"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
5
27
|
def visit_Arel_Nodes_Bin o
|
6
28
|
"BINARY #{visit o.expr}"
|
7
29
|
end
|
data/test/test_select_manager.rb
CHANGED
@@ -412,6 +412,15 @@ module Arel
|
|
412
412
|
ast = mgr.ast
|
413
413
|
mgr.visitor.accept(ast).must_equal mgr.to_sql
|
414
414
|
end
|
415
|
+
it 'should allow orders to work when the ast is grepped' do
|
416
|
+
table = Table.new :users
|
417
|
+
mgr = table.from table
|
418
|
+
mgr.project Arel.sql '*'
|
419
|
+
mgr.from table
|
420
|
+
mgr.orders << Arel::Nodes::Ascending.new(Arel.sql('foo'))
|
421
|
+
mgr.ast.grep(Arel::Nodes::OuterJoin)
|
422
|
+
mgr.to_sql.must_be_like %{ SELECT * FROM "users" ORDER BY foo ASC }
|
423
|
+
end
|
415
424
|
end
|
416
425
|
|
417
426
|
describe 'taken' do
|
data/test/visitors/test_mysql.rb
CHANGED
@@ -7,6 +7,16 @@ module Arel
|
|
7
7
|
@visitor = MySQL.new Table.engine
|
8
8
|
end
|
9
9
|
|
10
|
+
it 'squashes parenthesis on multiple unions' do
|
11
|
+
subnode = Nodes::Union.new 'left', 'right'
|
12
|
+
node = Nodes::Union.new subnode, 'topright'
|
13
|
+
assert_equal 1, @visitor.accept(node).scan('(').length
|
14
|
+
|
15
|
+
subnode = Nodes::Union.new 'left', 'right'
|
16
|
+
node = Nodes::Union.new 'topleft', subnode
|
17
|
+
assert_equal 1, @visitor.accept(node).scan('(').length
|
18
|
+
end
|
19
|
+
|
10
20
|
###
|
11
21
|
# :'(
|
12
22
|
# http://dev.mysql.com/doc/refman/5.0/en/select.html#id3482214
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
4
|
+
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 2
|
8
7
|
- 1
|
9
|
-
-
|
10
|
-
version: 2.1.
|
8
|
+
- 4
|
9
|
+
version: 2.1.4
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Aaron Patterson
|
@@ -18,23 +17,35 @@ autorequire:
|
|
18
17
|
bindir: bin
|
19
18
|
cert_chain: []
|
20
19
|
|
21
|
-
date: 2011-
|
20
|
+
date: 2011-07-25 00:00:00 -07:00
|
21
|
+
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
24
|
-
name:
|
24
|
+
name: minitest
|
25
25
|
prerelease: false
|
26
26
|
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
27
|
requirements:
|
29
28
|
- - ~>
|
30
29
|
- !ruby/object:Gem::Version
|
31
|
-
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 3
|
33
|
+
version: "2.3"
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: hoe
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
32
43
|
segments:
|
33
44
|
- 2
|
34
45
|
- 9
|
35
46
|
version: "2.9"
|
36
47
|
type: :development
|
37
|
-
version_requirements: *
|
48
|
+
version_requirements: *id002
|
38
49
|
description: |-
|
39
50
|
Arel is a SQL AST manager for Ruby. It
|
40
51
|
|
@@ -174,6 +185,7 @@ files:
|
|
174
185
|
- test/visitors/test_postgres.rb
|
175
186
|
- test/visitors/test_sqlite.rb
|
176
187
|
- test/visitors/test_to_sql.rb
|
188
|
+
has_rdoc: true
|
177
189
|
homepage: http://github.com/rails/arel
|
178
190
|
licenses: []
|
179
191
|
|
@@ -184,27 +196,23 @@ rdoc_options:
|
|
184
196
|
require_paths:
|
185
197
|
- lib
|
186
198
|
required_ruby_version: !ruby/object:Gem::Requirement
|
187
|
-
none: false
|
188
199
|
requirements:
|
189
200
|
- - ">="
|
190
201
|
- !ruby/object:Gem::Version
|
191
|
-
hash: 3
|
192
202
|
segments:
|
193
203
|
- 0
|
194
204
|
version: "0"
|
195
205
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
196
|
-
none: false
|
197
206
|
requirements:
|
198
207
|
- - ">="
|
199
208
|
- !ruby/object:Gem::Version
|
200
|
-
hash: 3
|
201
209
|
segments:
|
202
210
|
- 0
|
203
211
|
version: "0"
|
204
212
|
requirements: []
|
205
213
|
|
206
214
|
rubyforge_project: arel
|
207
|
-
rubygems_version: 1.
|
215
|
+
rubygems_version: 1.3.6
|
208
216
|
signing_key:
|
209
217
|
specification_version: 3
|
210
218
|
summary: Arel is a SQL AST manager for Ruby
|