arel 7.1.4 → 8.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 +6 -20
- data/README.md +2 -1
- data/lib/arel.rb +4 -1
- data/lib/arel/alias_predication.rb +1 -0
- data/lib/arel/attributes.rb +1 -0
- data/lib/arel/attributes/attribute.rb +1 -0
- data/lib/arel/collectors/bind.rb +1 -0
- data/lib/arel/collectors/plain_string.rb +2 -1
- data/lib/arel/collectors/sql_string.rb +1 -0
- data/lib/arel/compatibility/wheres.rb +1 -0
- data/lib/arel/crud.rb +1 -0
- data/lib/arel/delete_manager.rb +1 -0
- data/lib/arel/errors.rb +8 -0
- data/lib/arel/expressions.rb +1 -0
- data/lib/arel/factory_methods.rb +1 -0
- data/lib/arel/insert_manager.rb +1 -0
- data/lib/arel/math.rb +1 -0
- data/lib/arel/nodes.rb +1 -0
- data/lib/arel/nodes/and.rb +1 -0
- data/lib/arel/nodes/ascending.rb +1 -0
- data/lib/arel/nodes/binary.rb +1 -0
- data/lib/arel/nodes/bind_param.rb +1 -0
- data/lib/arel/nodes/case.rb +1 -0
- data/lib/arel/nodes/casted.rb +1 -0
- data/lib/arel/nodes/count.rb +1 -0
- data/lib/arel/nodes/delete_statement.rb +1 -0
- data/lib/arel/nodes/descending.rb +1 -0
- data/lib/arel/nodes/equality.rb +1 -0
- data/lib/arel/nodes/extract.rb +1 -0
- data/lib/arel/nodes/false.rb +1 -0
- data/lib/arel/nodes/full_outer_join.rb +1 -0
- data/lib/arel/nodes/function.rb +1 -0
- data/lib/arel/nodes/grouping.rb +1 -0
- data/lib/arel/nodes/in.rb +1 -0
- data/lib/arel/nodes/infix_operation.rb +1 -0
- data/lib/arel/nodes/inner_join.rb +1 -0
- data/lib/arel/nodes/insert_statement.rb +1 -0
- data/lib/arel/nodes/join_source.rb +1 -0
- data/lib/arel/nodes/matches.rb +1 -0
- data/lib/arel/nodes/named_function.rb +1 -0
- data/lib/arel/nodes/node.rb +1 -0
- data/lib/arel/nodes/outer_join.rb +1 -0
- data/lib/arel/nodes/over.rb +1 -0
- data/lib/arel/nodes/regexp.rb +1 -0
- data/lib/arel/nodes/right_outer_join.rb +1 -0
- data/lib/arel/nodes/select_core.rb +1 -0
- data/lib/arel/nodes/select_statement.rb +1 -0
- data/lib/arel/nodes/sql_literal.rb +1 -0
- data/lib/arel/nodes/string_join.rb +1 -0
- data/lib/arel/nodes/table_alias.rb +1 -0
- data/lib/arel/nodes/terminal.rb +1 -0
- data/lib/arel/nodes/true.rb +1 -0
- data/lib/arel/nodes/unary.rb +1 -0
- data/lib/arel/nodes/unary_operation.rb +1 -0
- data/lib/arel/nodes/unqualified_column.rb +1 -0
- data/lib/arel/nodes/update_statement.rb +1 -0
- data/lib/arel/nodes/values.rb +1 -0
- data/lib/arel/nodes/window.rb +1 -0
- data/lib/arel/nodes/with.rb +1 -0
- data/lib/arel/order_predications.rb +1 -0
- data/lib/arel/predications.rb +1 -0
- data/lib/arel/select_manager.rb +2 -1
- data/lib/arel/table.rb +2 -13
- data/lib/arel/tree_manager.rb +1 -0
- data/lib/arel/update_manager.rb +1 -0
- data/lib/arel/visitors.rb +1 -0
- data/lib/arel/visitors/bind_substitute.rb +1 -0
- data/lib/arel/visitors/bind_visitor.rb +1 -0
- data/lib/arel/visitors/depth_first.rb +1 -0
- data/lib/arel/visitors/dot.rb +2 -1
- data/lib/arel/visitors/ibm_db.rb +1 -0
- data/lib/arel/visitors/informix.rb +1 -0
- data/lib/arel/visitors/mssql.rb +1 -0
- data/lib/arel/visitors/mysql.rb +1 -0
- data/lib/arel/visitors/oracle.rb +2 -1
- data/lib/arel/visitors/oracle12.rb +1 -0
- data/lib/arel/visitors/postgresql.rb +1 -0
- data/lib/arel/visitors/reduce.rb +1 -0
- data/lib/arel/visitors/sqlite.rb +1 -0
- data/lib/arel/visitors/to_sql.rb +11 -49
- data/lib/arel/visitors/visitor.rb +1 -0
- data/lib/arel/visitors/where_sql.rb +1 -0
- data/lib/arel/window_predications.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d63929355e39f8b80a24e91781752eb2b152ff56
|
4
|
+
data.tar.gz: 5c67efb970c72f38f5d43619c52492f77af5f107
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 690294ba02d8416fa6204ec94a2a35d822aa3533d7767e5477da68572ca233cda12eae57eb6d1b4d619afc08e0ff29fc4f09b93a79fae8b83d4778cb351fbc3e
|
7
|
+
data.tar.gz: 6bb11f371d17dfc7ffb400e98b49ddad92b80f7095d8e4ff7e72a9c8555c0335f3da6ae08df96cc3641cd8784ea2fea11daaf5fc4b1c860df43eb011023ef18f
|
data/History.txt
CHANGED
@@ -1,29 +1,15 @@
|
|
1
|
-
===
|
1
|
+
=== 8.0.0 / 2017-02-21
|
2
2
|
|
3
|
-
*
|
4
|
-
|
5
|
-
* Remove deprecated usage inside arel.
|
6
|
-
|
7
|
-
=== 7.1.3 / 2016-10-07
|
8
|
-
|
9
|
-
* bug fixes
|
10
|
-
|
11
|
-
* Remove union mapping as :binary node when performing DepthFirst enumeration
|
12
|
-
* Fix invalid BindParam output in Dot visitor
|
13
|
-
* Add Arel::Nodes::Casted to dot visitor
|
14
|
-
* Use Arel::Nodes::BindParam in Oracle visitor for queries using both LIMIT and OFFSET
|
15
|
-
|
16
|
-
=== 7.1.2 / 2016-09-13
|
17
|
-
|
18
|
-
* bug fixes
|
3
|
+
* Enhancements
|
19
4
|
|
20
|
-
*
|
5
|
+
* Remove deprecated type casting support in Arel
|
6
|
+
* Frozen all string literals in Arel
|
21
7
|
|
22
8
|
=== 7.1.1 / 2016-07-27
|
23
9
|
|
24
|
-
*
|
10
|
+
* Bug Fixes
|
25
11
|
|
26
|
-
*
|
12
|
+
* Fix warning in `Casted#hash`
|
27
13
|
|
28
14
|
=== 7.1.0 / 2016-07-19
|
29
15
|
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Arel
|
2
2
|
|
3
3
|
* http://github.com/rails/arel
|
4
|
+
* [API Documentation](http://www.rubydoc.info/github/rails/arel)
|
4
5
|
|
5
6
|
## DESCRIPTION
|
6
7
|
|
@@ -97,7 +98,7 @@ users.where((users[:bitmap] >> 1).gt(0)).project(Arel.sql('*'))
|
|
97
98
|
# => SELECT * FROM "users" WHERE ("users"."bitmap" >> 1) > 0
|
98
99
|
|
99
100
|
users.where((~ users[:bitmap]).gt(0)).project(Arel.sql('*'))
|
100
|
-
# => SELECT FROM "users" WHERE ~ "users"."bitmap" > 0
|
101
|
+
# => SELECT * FROM "users" WHERE ~ "users"."bitmap" > 0
|
101
102
|
```
|
102
103
|
|
103
104
|
Joins resemble SQL strongly:
|
data/lib/arel.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'arel/errors'
|
3
|
+
|
1
4
|
require 'arel/crud'
|
2
5
|
require 'arel/factory_methods'
|
3
6
|
|
@@ -21,7 +24,7 @@ require 'arel/delete_manager'
|
|
21
24
|
require 'arel/nodes'
|
22
25
|
|
23
26
|
module Arel
|
24
|
-
VERSION = '
|
27
|
+
VERSION = '8.0.0'
|
25
28
|
|
26
29
|
def self.sql raw_sql
|
27
30
|
Arel::Nodes::SqlLiteral.new raw_sql
|
data/lib/arel/attributes.rb
CHANGED
data/lib/arel/collectors/bind.rb
CHANGED
data/lib/arel/crud.rb
CHANGED
data/lib/arel/delete_manager.rb
CHANGED
data/lib/arel/errors.rb
ADDED
data/lib/arel/expressions.rb
CHANGED
data/lib/arel/factory_methods.rb
CHANGED
data/lib/arel/insert_manager.rb
CHANGED
data/lib/arel/math.rb
CHANGED
data/lib/arel/nodes.rb
CHANGED
data/lib/arel/nodes/and.rb
CHANGED
data/lib/arel/nodes/ascending.rb
CHANGED
data/lib/arel/nodes/binary.rb
CHANGED
data/lib/arel/nodes/case.rb
CHANGED
data/lib/arel/nodes/casted.rb
CHANGED
data/lib/arel/nodes/count.rb
CHANGED
data/lib/arel/nodes/equality.rb
CHANGED
data/lib/arel/nodes/extract.rb
CHANGED
data/lib/arel/nodes/false.rb
CHANGED
data/lib/arel/nodes/function.rb
CHANGED
data/lib/arel/nodes/grouping.rb
CHANGED
data/lib/arel/nodes/in.rb
CHANGED
data/lib/arel/nodes/matches.rb
CHANGED
data/lib/arel/nodes/node.rb
CHANGED
data/lib/arel/nodes/over.rb
CHANGED
data/lib/arel/nodes/regexp.rb
CHANGED
data/lib/arel/nodes/terminal.rb
CHANGED
data/lib/arel/nodes/true.rb
CHANGED
data/lib/arel/nodes/unary.rb
CHANGED
data/lib/arel/nodes/values.rb
CHANGED
data/lib/arel/nodes/window.rb
CHANGED
data/lib/arel/nodes/with.rb
CHANGED
data/lib/arel/predications.rb
CHANGED
data/lib/arel/select_manager.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'arel/collectors/sql_string'
|
2
3
|
|
3
4
|
module Arel
|
@@ -106,7 +107,7 @@ module Arel
|
|
106
107
|
|
107
108
|
case relation
|
108
109
|
when String, Nodes::SqlLiteral
|
109
|
-
raise if relation.empty?
|
110
|
+
raise EmptyJoinError if relation.empty?
|
110
111
|
klass = Nodes::StringJoin
|
111
112
|
end
|
112
113
|
|
data/lib/arel/table.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Arel
|
2
3
|
class Table
|
3
4
|
include Arel::Crud
|
@@ -13,7 +14,6 @@ module Arel
|
|
13
14
|
|
14
15
|
def initialize(name, as: nil, type_caster: nil)
|
15
16
|
@name = name.to_s
|
16
|
-
@columns = nil
|
17
17
|
@type_caster = type_caster
|
18
18
|
|
19
19
|
# Sometime AR sends an :as parameter to table, to let the table know
|
@@ -38,7 +38,7 @@ module Arel
|
|
38
38
|
|
39
39
|
case relation
|
40
40
|
when String, Nodes::SqlLiteral
|
41
|
-
raise if relation.empty?
|
41
|
+
raise EmptyJoinError if relation.empty?
|
42
42
|
klass = Nodes::StringJoin
|
43
43
|
end
|
44
44
|
|
@@ -106,16 +106,5 @@ module Arel
|
|
106
106
|
protected
|
107
107
|
|
108
108
|
attr_reader :type_caster
|
109
|
-
|
110
|
-
private
|
111
|
-
|
112
|
-
def attributes_for columns
|
113
|
-
return nil unless columns
|
114
|
-
|
115
|
-
columns.map do |column|
|
116
|
-
Attributes.for(column).new self, column.name.to_sym
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
109
|
end
|
121
110
|
end
|
data/lib/arel/tree_manager.rb
CHANGED
data/lib/arel/update_manager.rb
CHANGED
data/lib/arel/visitors.rb
CHANGED
data/lib/arel/visitors/dot.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Arel
|
2
3
|
module Visitors
|
3
4
|
class Dot < Arel::Visitors::Visitor
|
@@ -277,7 +278,7 @@ module Arel
|
|
277
278
|
label = "<f0>#{node.name}"
|
278
279
|
|
279
280
|
node.fields.each_with_index do |field, i|
|
280
|
-
label
|
281
|
+
label += "|<f#{i + 1}>#{quote field}"
|
281
282
|
end
|
282
283
|
|
283
284
|
"#{node.id} [label=\"#{label}\"];"
|
data/lib/arel/visitors/ibm_db.rb
CHANGED
data/lib/arel/visitors/mssql.rb
CHANGED
data/lib/arel/visitors/mysql.rb
CHANGED
data/lib/arel/visitors/oracle.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Arel
|
2
3
|
module Visitors
|
3
4
|
class Oracle < Arel::Visitors::ToSql
|
@@ -136,7 +137,7 @@ module Arel
|
|
136
137
|
array[i] << ',' << part
|
137
138
|
else
|
138
139
|
# to ensure that array[i] will be String and not Arel::Nodes::SqlLiteral
|
139
|
-
array[i] =
|
140
|
+
array[i] = part.to_s
|
140
141
|
end
|
141
142
|
i += 1 if array[i].count('(') == array[i].count(')')
|
142
143
|
end
|
data/lib/arel/visitors/reduce.rb
CHANGED
data/lib/arel/visitors/sqlite.rb
CHANGED
data/lib/arel/visitors/to_sql.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'bigdecimal'
|
2
3
|
require 'date'
|
3
4
|
require 'arel/visitors/reduce'
|
@@ -75,15 +76,11 @@ module Arel
|
|
75
76
|
|
76
77
|
private
|
77
78
|
|
78
|
-
def schema_cache
|
79
|
-
@connection.schema_cache
|
80
|
-
end
|
81
|
-
|
82
79
|
def visit_Arel_Nodes_DeleteStatement o, collector
|
83
80
|
collector << 'DELETE FROM '
|
84
81
|
collector = visit o.relation, collector
|
85
82
|
if o.wheres.any?
|
86
|
-
collector <<
|
83
|
+
collector << WHERE
|
87
84
|
collector = inject_join o.wheres, collector, AND
|
88
85
|
end
|
89
86
|
|
@@ -169,34 +166,16 @@ module Arel
|
|
169
166
|
collector << "FALSE"
|
170
167
|
end
|
171
168
|
|
172
|
-
def table_exists? name
|
173
|
-
schema_cache.data_source_exists?(name)
|
174
|
-
end
|
175
|
-
|
176
|
-
def column_for attr
|
177
|
-
return unless attr
|
178
|
-
name = attr.name.to_s
|
179
|
-
table = attr.relation.table_name
|
180
|
-
|
181
|
-
return nil unless table_exists? table
|
182
|
-
|
183
|
-
column_cache(table)[name]
|
184
|
-
end
|
185
|
-
|
186
|
-
def column_cache(table)
|
187
|
-
schema_cache.columns_hash(table)
|
188
|
-
end
|
189
|
-
|
190
169
|
def visit_Arel_Nodes_Values o, collector
|
191
170
|
collector << "VALUES ("
|
192
171
|
|
193
172
|
len = o.expressions.length - 1
|
194
|
-
o.expressions.
|
173
|
+
o.expressions.each_with_index { |value, i|
|
195
174
|
case value
|
196
175
|
when Nodes::SqlLiteral, Nodes::BindParam
|
197
176
|
collector = visit value, collector
|
198
177
|
else
|
199
|
-
collector << quote(value
|
178
|
+
collector << quote(value).to_s
|
200
179
|
end
|
201
180
|
unless i == len
|
202
181
|
collector << COMMA
|
@@ -286,12 +265,12 @@ module Arel
|
|
286
265
|
|
287
266
|
def visit_Arel_Nodes_With o, collector
|
288
267
|
collector << "WITH "
|
289
|
-
inject_join o.children, collector,
|
268
|
+
inject_join o.children, collector, COMMA
|
290
269
|
end
|
291
270
|
|
292
271
|
def visit_Arel_Nodes_WithRecursive o, collector
|
293
272
|
collector << "WITH RECURSIVE "
|
294
|
-
inject_join o.children, collector,
|
273
|
+
inject_join o.children, collector, COMMA
|
295
274
|
end
|
296
275
|
|
297
276
|
def visit_Arel_Nodes_Union o, collector
|
@@ -545,7 +524,7 @@ module Arel
|
|
545
524
|
end
|
546
525
|
if o.right.any?
|
547
526
|
collector << SPACE if o.left
|
548
|
-
collector = inject_join o.right, collector,
|
527
|
+
collector = inject_join o.right, collector, SPACE
|
549
528
|
end
|
550
529
|
collector
|
551
530
|
end
|
@@ -652,7 +631,7 @@ module Arel
|
|
652
631
|
else
|
653
632
|
collector = visit o.left, collector
|
654
633
|
collector << " = "
|
655
|
-
collector << quote(o.right
|
634
|
+
collector << quote(o.right).to_s
|
656
635
|
end
|
657
636
|
end
|
658
637
|
|
@@ -748,7 +727,7 @@ module Arel
|
|
748
727
|
if a && a.able_to_type_cast?
|
749
728
|
quote(a.type_cast_for_database(o))
|
750
729
|
else
|
751
|
-
quote(o
|
730
|
+
quote(o)
|
752
731
|
end
|
753
732
|
end
|
754
733
|
|
@@ -792,12 +771,9 @@ module Arel
|
|
792
771
|
end
|
793
772
|
alias :visit_Set :visit_Array
|
794
773
|
|
795
|
-
def quote value
|
774
|
+
def quote value
|
796
775
|
return value if Arel::Nodes::SqlLiteral === value
|
797
|
-
|
798
|
-
print_type_cast_deprecation
|
799
|
-
end
|
800
|
-
@connection.quote value, column
|
776
|
+
@connection.quote value
|
801
777
|
end
|
802
778
|
|
803
779
|
def quote_table_name name
|
@@ -846,20 +822,6 @@ module Arel
|
|
846
822
|
collector
|
847
823
|
end
|
848
824
|
end
|
849
|
-
|
850
|
-
def print_type_cast_deprecation
|
851
|
-
unless defined?($arel_silence_type_casting_deprecation) && $arel_silence_type_casting_deprecation
|
852
|
-
warn <<-eowarn
|
853
|
-
Arel performing automatic type casting is deprecated, and will be removed in Arel 8.0. If you are seeing this, it is because you are manually passing a value to an Arel predicate, and the `Arel::Table` object was constructed manually. The easiest way to remove this warning is to use an `Arel::Table` object returned from calling `arel_table` on an ActiveRecord::Base subclass.
|
854
|
-
|
855
|
-
If you're certain the value is already of the right type, change `attribute.eq(value)` to `attribute.eq(Arel::Nodes::Quoted.new(value))` (you will be able to remove that in Arel 8.0, it is only required to silence this deprecation warning).
|
856
|
-
|
857
|
-
You can also silence this warning globally by setting `$arel_silence_type_casting_deprecation` to `true`. (Do NOT do this if you are a library author)
|
858
|
-
|
859
|
-
If you are passing user input to a predicate, you must either give an appropriate type caster object to the `Arel::Table`, or manually cast the value before passing it to Arel.
|
860
|
-
eowarn
|
861
|
-
end
|
862
|
-
end
|
863
825
|
end
|
864
826
|
end
|
865
827
|
end
|
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: 8.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2017-02-21 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: minitest
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/arel/compatibility/wheres.rb
|
91
91
|
- lib/arel/crud.rb
|
92
92
|
- lib/arel/delete_manager.rb
|
93
|
+
- lib/arel/errors.rb
|
93
94
|
- lib/arel/expressions.rb
|
94
95
|
- lib/arel/factory_methods.rb
|
95
96
|
- lib/arel/insert_manager.rb
|
@@ -182,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
183
|
version: '0'
|
183
184
|
requirements: []
|
184
185
|
rubyforge_project:
|
185
|
-
rubygems_version: 2.
|
186
|
+
rubygems_version: 2.6.10
|
186
187
|
signing_key:
|
187
188
|
specification_version: 4
|
188
189
|
summary: Arel Really Exasperates Logicians Arel is a SQL AST manager for Ruby
|