arel 4.0.2 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +57 -3
- data/Manifest.txt +0 -1
- data/README.markdown +4 -7
- data/arel.gemspec +14 -14
- data/lib/arel.rb +1 -1
- data/lib/arel/crud.rb +2 -34
- data/lib/arel/select_manager.rb +0 -38
- data/lib/arel/table.rb +0 -21
- data/lib/arel/visitors/postgresql.rb +0 -2
- data/lib/arel/visitors/to_sql.rb +1 -11
- data/test/test_crud.rb +1 -1
- data/test/test_select_manager.rb +6 -20
- data/test/visitors/test_postgres.rb +0 -36
- data/test/visitors/test_to_sql.rb +0 -34
- metadata +20 -22
- data/test/test_activerecord_compat.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e4a4617ad12bc06100404774da8861b906302a0
|
4
|
+
data.tar.gz: ef0b304f87d0607f4225cda23a84fe972fa5f5d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8f247d114fe817f8efa0810ed924f791fda25b55fa2f998449150c31e42dd1c8c10bf56d2c3afbcc4f6344962ada47ef0b503deedc995df10eb9c103827f1ba
|
7
|
+
data.tar.gz: 6fad98f033050e0556bed7ba338b8e7456b2758c62d58f98709c768f3e1496adf1a9f3d2e241be1c0f289c4fd91c694adec01c452f933f8caeef6495ccdca901
|
data/History.txt
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
-
|
1
|
+
== 5.0.0 / 2013-12-04
|
2
|
+
|
3
|
+
* Enhancements
|
4
|
+
|
5
|
+
* Remove deprecated code
|
2
6
|
|
3
7
|
* Bug Fixes
|
4
8
|
|
5
|
-
* Fix `
|
6
|
-
* PostgreSQL bugfix for invalid SQL in subqueries
|
9
|
+
* Fix serializing a relation when calling `to_yaml`
|
7
10
|
|
8
11
|
== 4.0.1 / 2013-10-22
|
9
12
|
|
@@ -17,6 +20,57 @@
|
|
17
20
|
* Make visitors threadsafe by removing @last_column
|
18
21
|
* Support `columns_for_distinct` with Oracle adapter
|
19
22
|
|
23
|
+
== 3.0.3 / 2013-11-12
|
24
|
+
|
25
|
+
* Enhancements
|
26
|
+
|
27
|
+
* Support ANSI 2003 window functions
|
28
|
+
|
29
|
+
* Bug Fixes
|
30
|
+
|
31
|
+
* Fix joins in Informix
|
32
|
+
|
33
|
+
== 3.0.2 / 2012-02-21
|
34
|
+
|
35
|
+
* Enhancements
|
36
|
+
|
37
|
+
* Added a module for visiting and transforming bind values
|
38
|
+
* Fix in [] to be false, not in [] to be true
|
39
|
+
|
40
|
+
* Bug Fixes
|
41
|
+
|
42
|
+
* Revert fix for LIMIT / OFFSET when query is ordered in Oracle
|
43
|
+
|
44
|
+
== 3.0.1 / 2012-02-17
|
45
|
+
|
46
|
+
* Bug Fixes
|
47
|
+
|
48
|
+
* Fixed LIMIT / OFFSET when query is ordered in Oracle
|
49
|
+
|
50
|
+
== 3.0.0 / 2012-01-12
|
51
|
+
|
52
|
+
* Enhancements
|
53
|
+
|
54
|
+
* Support connection pool and schema cache
|
55
|
+
|
56
|
+
* Bug Fixes
|
57
|
+
|
58
|
+
* Conditions with no column can be followed by other conditions in Postgres
|
59
|
+
|
60
|
+
== 2.2.3 / 2012-02-21
|
61
|
+
|
62
|
+
* Enhancements
|
63
|
+
|
64
|
+
* Added a module for visiting and transforming bind values
|
65
|
+
|
66
|
+
== 2.2.2 / 2012-02-20
|
67
|
+
|
68
|
+
* Enhancements
|
69
|
+
|
70
|
+
* Support LOCK
|
71
|
+
* Allow using non-table alias as a right-hand relation name
|
72
|
+
* Added SelectManager#distinct
|
73
|
+
|
20
74
|
== 2.2.1 / 2011-09-15
|
21
75
|
|
22
76
|
* Enhancements
|
data/Manifest.txt
CHANGED
data/README.markdown
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
Arel is a SQL AST manager for Ruby. It
|
8
8
|
|
9
9
|
1. Simplifies the generation of complex SQL queries
|
10
|
-
2. Adapts to various
|
10
|
+
2. Adapts to various RDBMSes
|
11
11
|
|
12
12
|
It is intended to be a framework framework; that is, you can build your own ORM
|
13
13
|
with it, focusing on innovative object and collection modeling as opposed to
|
@@ -111,12 +111,10 @@ Suppose we have a table `products` with prices in different currencies. And we h
|
|
111
111
|
|
112
112
|
```ruby
|
113
113
|
products = Arel::Table.new(:products)
|
114
|
-
|
115
|
-
# => [products[:id], products[:name], products[:price], products[:currency_id]]
|
114
|
+
# Attributes: [:id, :name, :price, :currency_id]
|
116
115
|
|
117
116
|
currency_rates = Arel::Table.new(:currency_rates)
|
118
|
-
|
119
|
-
# => [currency_rates[:from_id], currency_rates[:to_id], currency_rates[:date], currency_rates[:rate]]
|
117
|
+
# Attributes: [:from_id, :to_id, :date, :rate]
|
120
118
|
```
|
121
119
|
|
122
120
|
Now, to order products by price in user preferred currency simply call:
|
@@ -139,8 +137,7 @@ comments = Arel::Table.new(:comments)
|
|
139
137
|
And this table has the following attributes:
|
140
138
|
|
141
139
|
```ruby
|
142
|
-
|
143
|
-
# => [comments[:id], comments[:body], comments[:parent_id]]
|
140
|
+
# [:id, :body, :parent_id]
|
144
141
|
```
|
145
142
|
|
146
143
|
The `parent_id` column is a foreign key from the `comments` table to itself. Now, joining a table to itself requires aliasing in SQL. In fact, you may alias in Arel as well:
|
data/arel.gemspec
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: arel
|
2
|
+
# stub: arel 5.0.0.20131204235845 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "arel"
|
6
|
-
s.version = "
|
6
|
+
s.version = "5.0.0.20131204235845"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
|
-
s.require_paths = ["lib"]
|
10
9
|
s.authors = ["Aaron Patterson", "Bryan Halmkamp", "Emilio Tagua", "Nick Kallen"]
|
11
|
-
s.date = "
|
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
|
10
|
+
s.date = "2013-12-05"
|
11
|
+
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."
|
13
12
|
s.email = ["aaron@tenderlovemaking.com", "bryan@brynary.com", "miloops@gmail.com", "nick@example.org"]
|
14
13
|
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/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/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/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/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_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/
|
14
|
+
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/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/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/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_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_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"]
|
16
15
|
s.homepage = "http://github.com/rails/arel"
|
17
16
|
s.licenses = ["MIT"]
|
18
17
|
s.rdoc_options = ["--main", "README.markdown"]
|
18
|
+
s.require_paths = ["lib"]
|
19
19
|
s.rubyforge_project = "arel"
|
20
|
-
s.rubygems_version = "2.
|
20
|
+
s.rubygems_version = "2.1.11"
|
21
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/
|
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/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"]
|
23
23
|
|
24
24
|
if s.respond_to? :specification_version then
|
25
25
|
s.specification_version = 4
|
26
26
|
|
27
27
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
28
|
-
s.add_development_dependency(%q<minitest>, ["~> 5.
|
28
|
+
s.add_development_dependency(%q<minitest>, ["~> 5.0"])
|
29
29
|
s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
|
30
|
-
s.add_development_dependency(%q<hoe>, ["~> 3.
|
30
|
+
s.add_development_dependency(%q<hoe>, ["~> 3.7"])
|
31
31
|
else
|
32
|
-
s.add_dependency(%q<minitest>, ["~> 5.
|
32
|
+
s.add_dependency(%q<minitest>, ["~> 5.0"])
|
33
33
|
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
34
|
-
s.add_dependency(%q<hoe>, ["~> 3.
|
34
|
+
s.add_dependency(%q<hoe>, ["~> 3.7"])
|
35
35
|
end
|
36
36
|
else
|
37
|
-
s.add_dependency(%q<minitest>, ["~> 5.
|
37
|
+
s.add_dependency(%q<minitest>, ["~> 5.0"])
|
38
38
|
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
39
|
-
s.add_dependency(%q<hoe>, ["~> 3.
|
39
|
+
s.add_dependency(%q<hoe>, ["~> 3.7"])
|
40
40
|
end
|
41
41
|
end
|
data/lib/arel.rb
CHANGED
data/lib/arel/crud.rb
CHANGED
@@ -2,7 +2,7 @@ module Arel
|
|
2
2
|
###
|
3
3
|
# FIXME hopefully we can remove this
|
4
4
|
module Crud
|
5
|
-
def compile_update values
|
5
|
+
def compile_update values, pk
|
6
6
|
um = UpdateManager.new @engine
|
7
7
|
|
8
8
|
if Nodes::SqlLiteral === values
|
@@ -10,6 +10,7 @@ module Arel
|
|
10
10
|
else
|
11
11
|
relation = values.first.first.relation
|
12
12
|
end
|
13
|
+
um.key = pk
|
13
14
|
um.table relation
|
14
15
|
um.set values
|
15
16
|
um.take @ast.limit.expr if @ast.limit
|
@@ -18,19 +19,6 @@ module Arel
|
|
18
19
|
um
|
19
20
|
end
|
20
21
|
|
21
|
-
# FIXME: this method should go away
|
22
|
-
def update values
|
23
|
-
if $VERBOSE
|
24
|
-
warn <<-eowarn
|
25
|
-
update (#{caller.first}) is deprecated and will be removed in Arel 4.0.0. Please
|
26
|
-
switch to `compile_update`
|
27
|
-
eowarn
|
28
|
-
end
|
29
|
-
|
30
|
-
um = compile_update values
|
31
|
-
@engine.connection.update um.to_sql, 'AREL'
|
32
|
-
end
|
33
|
-
|
34
22
|
def compile_insert values
|
35
23
|
im = create_insert
|
36
24
|
im.insert values
|
@@ -41,17 +29,6 @@ switch to `compile_update`
|
|
41
29
|
InsertManager.new @engine
|
42
30
|
end
|
43
31
|
|
44
|
-
# FIXME: this method should go away
|
45
|
-
def insert values
|
46
|
-
if $VERBOSE
|
47
|
-
warn <<-eowarn
|
48
|
-
insert (#{caller.first}) is deprecated and will be removed in Arel 4.0.0. Please
|
49
|
-
switch to `compile_insert`
|
50
|
-
eowarn
|
51
|
-
end
|
52
|
-
@engine.connection.insert compile_insert(values).to_sql
|
53
|
-
end
|
54
|
-
|
55
32
|
def compile_delete
|
56
33
|
dm = DeleteManager.new @engine
|
57
34
|
dm.wheres = @ctx.wheres
|
@@ -59,14 +36,5 @@ switch to `compile_insert`
|
|
59
36
|
dm
|
60
37
|
end
|
61
38
|
|
62
|
-
def delete
|
63
|
-
if $VERBOSE
|
64
|
-
warn <<-eowarn
|
65
|
-
delete (#{caller.first}) is deprecated and will be removed in Arel 4.0.0. Please
|
66
|
-
switch to `compile_delete`
|
67
|
-
eowarn
|
68
|
-
end
|
69
|
-
@engine.connection.delete compile_delete.to_sql, 'AREL'
|
70
|
-
end
|
71
39
|
end
|
72
40
|
end
|
data/lib/arel/select_manager.rb
CHANGED
@@ -47,14 +47,6 @@ module Arel
|
|
47
47
|
create_table_alias grouping(@ast), Nodes::SqlLiteral.new(other)
|
48
48
|
end
|
49
49
|
|
50
|
-
def where_clauses
|
51
|
-
if $VERBOSE
|
52
|
-
warn "(#{caller.first}) where_clauses is deprecated and will be removed in arel 4.0.0 with no replacement"
|
53
|
-
end
|
54
|
-
to_sql = Visitors::ToSql.new @engine.connection
|
55
|
-
@ctx.wheres.map { |c| to_sql.accept c }
|
56
|
-
end
|
57
|
-
|
58
50
|
def lock locking = Arel.sql('FOR UPDATE')
|
59
51
|
case locking
|
60
52
|
when true
|
@@ -169,11 +161,6 @@ module Arel
|
|
169
161
|
@ast.orders
|
170
162
|
end
|
171
163
|
|
172
|
-
def wheres
|
173
|
-
warn "#{caller[0]}: SelectManager#wheres is deprecated and will be removed in Arel 4.0.0 with no replacement"
|
174
|
-
Compatibility::Wheres.new @engine.connection, @ctx.wheres
|
175
|
-
end
|
176
|
-
|
177
164
|
def where_sql
|
178
165
|
return if @ctx.wheres.empty?
|
179
166
|
|
@@ -272,31 +259,6 @@ module Arel
|
|
272
259
|
@engine.connection.send(:select, to_sql, 'AREL').map { |x| Row.new(x) }
|
273
260
|
end
|
274
261
|
|
275
|
-
# FIXME: this method should go away
|
276
|
-
def insert values
|
277
|
-
if $VERBOSE
|
278
|
-
warn <<-eowarn
|
279
|
-
insert (#{caller.first}) is deprecated and will be removed in Arel 4.0.0. Please
|
280
|
-
switch to `compile_insert`
|
281
|
-
eowarn
|
282
|
-
end
|
283
|
-
|
284
|
-
im = compile_insert(values)
|
285
|
-
table = @ctx.froms
|
286
|
-
|
287
|
-
primary_key = table.primary_key
|
288
|
-
primary_key_name = primary_key.name if primary_key
|
289
|
-
|
290
|
-
# FIXME: in AR tests values sometimes were Array and not Hash therefore is_a?(Hash) check is added
|
291
|
-
primary_key_value = primary_key && values.is_a?(Hash) && values[primary_key]
|
292
|
-
im.into table
|
293
|
-
# Oracle adapter needs primary key name to generate RETURNING ... INTO ... clause
|
294
|
-
# for tables which assign primary key value using trigger.
|
295
|
-
# RETURNING ... INTO ... clause will be added only if primary_key_value is nil
|
296
|
-
# therefore it is necessary to pass primary key value as well
|
297
|
-
@engine.connection.insert im.to_sql, 'AREL', primary_key_name, primary_key_value
|
298
|
-
end
|
299
|
-
|
300
262
|
private
|
301
263
|
def collapse exprs, existing = nil
|
302
264
|
exprs = exprs.unshift(existing.expr) if existing
|
data/lib/arel/table.rb
CHANGED
@@ -100,17 +100,6 @@ primary_key (#{caller.first}) is deprecated and will be removed in Arel 4.0.0
|
|
100
100
|
from(self).having expr
|
101
101
|
end
|
102
102
|
|
103
|
-
def columns
|
104
|
-
if $VERBOSE
|
105
|
-
warn <<-eowarn
|
106
|
-
(#{caller.first}) Arel::Table#columns is deprecated and will be removed in
|
107
|
-
Arel 4.0.0 with no replacement. PEW PEW PEW!!!
|
108
|
-
eowarn
|
109
|
-
end
|
110
|
-
@columns ||=
|
111
|
-
attributes_for @engine.connection.columns(@name, "#{@name} Columns")
|
112
|
-
end
|
113
|
-
|
114
103
|
def [] name
|
115
104
|
::Arel::Attribute.new self, name
|
116
105
|
end
|
@@ -149,15 +138,5 @@ Arel 4.0.0 with no replacement. PEW PEW PEW!!!
|
|
149
138
|
end
|
150
139
|
end
|
151
140
|
|
152
|
-
@@table_cache = nil
|
153
|
-
def self.table_cache engine # :nodoc:
|
154
|
-
if $VERBOSE
|
155
|
-
warn <<-eowarn
|
156
|
-
(#{caller.first}) Arel::Table.table_cache is deprecated and will be removed in
|
157
|
-
Arel 4.0.0 with no replacement. PEW PEW PEW!!!
|
158
|
-
eowarn
|
159
|
-
end
|
160
|
-
@@table_cache ||= Hash[engine.connection.tables.map { |x| [x,true] }]
|
161
|
-
end
|
162
141
|
end
|
163
142
|
end
|
@@ -4,12 +4,10 @@ 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
|
8
7
|
"#{visit o.left, a} ILIKE #{visit o.right, a}"
|
9
8
|
end
|
10
9
|
|
11
10
|
def visit_Arel_Nodes_DoesNotMatch o, a
|
12
|
-
a = o.left if Arel::Attributes::Attribute === o.left
|
13
11
|
"#{visit o.left, a} NOT ILIKE #{visit o.right, a}"
|
14
12
|
end
|
15
13
|
|
data/lib/arel/visitors/to_sql.rb
CHANGED
@@ -85,17 +85,7 @@ module Arel
|
|
85
85
|
if o.orders.empty? && o.limit.nil?
|
86
86
|
wheres = o.wheres
|
87
87
|
else
|
88
|
-
|
89
|
-
unless key
|
90
|
-
warn(<<-eowarn) if $VERBOSE
|
91
|
-
(#{caller.first}) Using UpdateManager without setting UpdateManager#key is
|
92
|
-
deprecated and support will be removed in Arel 4.0.0. Please set the primary
|
93
|
-
key on UpdateManager using UpdateManager#key= '#{key.inspect}'
|
94
|
-
eowarn
|
95
|
-
key = o.relation.primary_key
|
96
|
-
end
|
97
|
-
|
98
|
-
wheres = [Nodes::In.new(key, [build_subselect(key, o)])]
|
88
|
+
wheres = [Nodes::In.new(o.key, [build_subselect(o.key, o)])]
|
99
89
|
end
|
100
90
|
|
101
91
|
[
|
data/test/test_crud.rb
CHANGED
@@ -45,7 +45,7 @@ module Arel
|
|
45
45
|
table = Table.new :users
|
46
46
|
fc = FakeCrudder.new
|
47
47
|
fc.from table
|
48
|
-
stmt = fc.compile_update [[table[:id], 'foo']]
|
48
|
+
stmt = fc.compile_update [[table[:id], 'foo']], table.primary_key
|
49
49
|
assert_instance_of Arel::UpdateManager, stmt
|
50
50
|
end
|
51
51
|
end
|
data/test/test_select_manager.rb
CHANGED
@@ -435,20 +435,6 @@ module Arel
|
|
435
435
|
end
|
436
436
|
end
|
437
437
|
|
438
|
-
describe 'insert' do
|
439
|
-
it 'uses the select FROM' do
|
440
|
-
engine = EngineProxy.new Table.engine
|
441
|
-
table = Table.new :users
|
442
|
-
manager = Arel::SelectManager.new engine
|
443
|
-
manager.from table
|
444
|
-
manager.insert 'VALUES(NULL)'
|
445
|
-
|
446
|
-
engine.executed.last.must_be_like %{
|
447
|
-
INSERT INTO "users" VALUES(NULL)
|
448
|
-
}
|
449
|
-
end
|
450
|
-
end
|
451
|
-
|
452
438
|
describe 'lock' do
|
453
439
|
# This should fail on other databases
|
454
440
|
it 'adds a lock node' do
|
@@ -935,7 +921,7 @@ module Arel
|
|
935
921
|
manager = Arel::SelectManager.new engine
|
936
922
|
manager.from table
|
937
923
|
manager.take 1
|
938
|
-
stmt = manager.compile_update(SqlLiteral.new('foo = bar'))
|
924
|
+
stmt = manager.compile_update(SqlLiteral.new('foo = bar'), table.primary_key)
|
939
925
|
stmt.key = table['id']
|
940
926
|
|
941
927
|
stmt.to_sql.must_be_like %{
|
@@ -950,7 +936,7 @@ module Arel
|
|
950
936
|
manager = Arel::SelectManager.new engine
|
951
937
|
manager.from table
|
952
938
|
manager.order :foo
|
953
|
-
stmt = manager.compile_update(SqlLiteral.new('foo = bar'))
|
939
|
+
stmt = manager.compile_update(SqlLiteral.new('foo = bar'), table.primary_key)
|
954
940
|
stmt.key = table['id']
|
955
941
|
|
956
942
|
stmt.to_sql.must_be_like %{
|
@@ -964,7 +950,7 @@ module Arel
|
|
964
950
|
table = Table.new :users
|
965
951
|
manager = Arel::SelectManager.new engine
|
966
952
|
manager.from table
|
967
|
-
stmt = manager.compile_update(SqlLiteral.new('foo = bar'))
|
953
|
+
stmt = manager.compile_update(SqlLiteral.new('foo = bar'), table.primary_key)
|
968
954
|
|
969
955
|
stmt.to_sql.must_be_like %{ UPDATE "users" SET foo = bar }
|
970
956
|
end
|
@@ -975,7 +961,7 @@ module Arel
|
|
975
961
|
manager = Arel::SelectManager.new engine
|
976
962
|
manager.where table[:id].eq 10
|
977
963
|
manager.from table
|
978
|
-
stmt = manager.compile_update(table[:id] => 1)
|
964
|
+
stmt = manager.compile_update({table[:id] => 1}, table.primary_key)
|
979
965
|
|
980
966
|
stmt.to_sql.must_be_like %{
|
981
967
|
UPDATE "users" SET "id" = 1 WHERE "users"."id" = 10
|
@@ -989,7 +975,7 @@ module Arel
|
|
989
975
|
manager.where table[:foo].eq 10
|
990
976
|
manager.take 42
|
991
977
|
manager.from table
|
992
|
-
stmt = manager.compile_update(table[:id] => 1)
|
978
|
+
stmt = manager.compile_update({table[:id] => 1}, table.primary_key)
|
993
979
|
|
994
980
|
stmt.to_sql.must_be_like %{
|
995
981
|
UPDATE "users" SET "id" = 1 WHERE "users"."id" IN (SELECT "users"."id" FROM "users" WHERE "users"."foo" = 10 LIMIT 42)
|
@@ -1001,7 +987,7 @@ module Arel
|
|
1001
987
|
table = Table.new :users
|
1002
988
|
manager = Arel::SelectManager.new engine
|
1003
989
|
manager.from table
|
1004
|
-
stmt = manager.compile_update(table[:id] => 1)
|
990
|
+
stmt = manager.compile_update({table[:id] => 1}, table.primary_key)
|
1005
991
|
|
1006
992
|
stmt.to_sql.must_be_like %{
|
1007
993
|
UPDATE "users" SET "id" = 1
|
@@ -5,8 +5,6 @@ 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]
|
10
8
|
end
|
11
9
|
|
12
10
|
describe 'locking' do
|
@@ -45,40 +43,6 @@ module Arel
|
|
45
43
|
core.set_quantifier = Arel::Nodes::Distinct.new
|
46
44
|
assert_equal 'SELECT DISTINCT', @visitor.accept(core)
|
47
45
|
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
|
82
46
|
end
|
83
47
|
end
|
84
48
|
end
|
@@ -194,40 +194,6 @@ 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
|
-
|
231
197
|
describe "Nodes::Ordering" do
|
232
198
|
it "should know how to visit" do
|
233
199
|
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
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
@@ -11,55 +11,55 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2013-12-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.0'
|
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.0'
|
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.7'
|
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.7'
|
58
58
|
description: |-
|
59
59
|
Arel is a SQL AST manager for Ruby. It
|
60
60
|
|
61
61
|
1. Simplifies the generation of complex SQL queries
|
62
|
-
2. Adapts to various
|
62
|
+
2. Adapts to various RDBMSes
|
63
63
|
|
64
64
|
It is intended to be a framework framework; that is, you can build your own ORM
|
65
65
|
with it, focusing on innovative object and collection modeling as opposed to
|
@@ -77,9 +77,9 @@ extra_rdoc_files:
|
|
77
77
|
- Manifest.txt
|
78
78
|
- README.markdown
|
79
79
|
files:
|
80
|
-
-
|
81
|
-
-
|
82
|
-
-
|
80
|
+
- .autotest
|
81
|
+
- .gemtest
|
82
|
+
- .travis.yml
|
83
83
|
- Gemfile
|
84
84
|
- History.txt
|
85
85
|
- MIT-LICENSE.txt
|
@@ -189,7 +189,6 @@ files:
|
|
189
189
|
- test/nodes/test_update_statement.rb
|
190
190
|
- test/nodes/test_window.rb
|
191
191
|
- test/support/fake_record.rb
|
192
|
-
- test/test_activerecord_compat.rb
|
193
192
|
- test/test_attributes.rb
|
194
193
|
- test/test_crud.rb
|
195
194
|
- test/test_delete_manager.rb
|
@@ -217,23 +216,23 @@ licenses:
|
|
217
216
|
metadata: {}
|
218
217
|
post_install_message:
|
219
218
|
rdoc_options:
|
220
|
-
-
|
219
|
+
- --main
|
221
220
|
- README.markdown
|
222
221
|
require_paths:
|
223
222
|
- lib
|
224
223
|
required_ruby_version: !ruby/object:Gem::Requirement
|
225
224
|
requirements:
|
226
|
-
- -
|
225
|
+
- - '>='
|
227
226
|
- !ruby/object:Gem::Version
|
228
227
|
version: '0'
|
229
228
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
230
229
|
requirements:
|
231
|
-
- -
|
230
|
+
- - '>='
|
232
231
|
- !ruby/object:Gem::Version
|
233
232
|
version: '0'
|
234
233
|
requirements: []
|
235
234
|
rubyforge_project: arel
|
236
|
-
rubygems_version: 2.
|
235
|
+
rubygems_version: 2.1.11
|
237
236
|
signing_key:
|
238
237
|
specification_version: 4
|
239
238
|
summary: Arel is a SQL AST manager for Ruby
|
@@ -266,7 +265,6 @@ test_files:
|
|
266
265
|
- test/nodes/test_true.rb
|
267
266
|
- test/nodes/test_update_statement.rb
|
268
267
|
- test/nodes/test_window.rb
|
269
|
-
- test/test_activerecord_compat.rb
|
270
268
|
- test/test_attributes.rb
|
271
269
|
- test/test_crud.rb
|
272
270
|
- test/test_delete_manager.rb
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
module Arel
|
4
|
-
describe 'activerecord compatibility' do
|
5
|
-
describe 'select manager' do
|
6
|
-
it 'provides wheres' do
|
7
|
-
table = Table.new :users
|
8
|
-
manager = Arel::SelectManager.new Table.engine
|
9
|
-
manager.where table[:id].eq 1
|
10
|
-
manager.where table[:name].eq 'Aaron'
|
11
|
-
|
12
|
-
manager.wheres.map { |x|
|
13
|
-
x.value
|
14
|
-
}.join(', ').must_equal "\"users\".\"id\" = 1, \"users\".\"name\" = 'Aaron'"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|