arel 7.1.4 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/History.txt +6 -20
  3. data/README.md +2 -1
  4. data/lib/arel.rb +4 -1
  5. data/lib/arel/alias_predication.rb +1 -0
  6. data/lib/arel/attributes.rb +1 -0
  7. data/lib/arel/attributes/attribute.rb +1 -0
  8. data/lib/arel/collectors/bind.rb +1 -0
  9. data/lib/arel/collectors/plain_string.rb +2 -1
  10. data/lib/arel/collectors/sql_string.rb +1 -0
  11. data/lib/arel/compatibility/wheres.rb +1 -0
  12. data/lib/arel/crud.rb +1 -0
  13. data/lib/arel/delete_manager.rb +1 -0
  14. data/lib/arel/errors.rb +8 -0
  15. data/lib/arel/expressions.rb +1 -0
  16. data/lib/arel/factory_methods.rb +1 -0
  17. data/lib/arel/insert_manager.rb +1 -0
  18. data/lib/arel/math.rb +1 -0
  19. data/lib/arel/nodes.rb +1 -0
  20. data/lib/arel/nodes/and.rb +1 -0
  21. data/lib/arel/nodes/ascending.rb +1 -0
  22. data/lib/arel/nodes/binary.rb +1 -0
  23. data/lib/arel/nodes/bind_param.rb +1 -0
  24. data/lib/arel/nodes/case.rb +1 -0
  25. data/lib/arel/nodes/casted.rb +1 -0
  26. data/lib/arel/nodes/count.rb +1 -0
  27. data/lib/arel/nodes/delete_statement.rb +1 -0
  28. data/lib/arel/nodes/descending.rb +1 -0
  29. data/lib/arel/nodes/equality.rb +1 -0
  30. data/lib/arel/nodes/extract.rb +1 -0
  31. data/lib/arel/nodes/false.rb +1 -0
  32. data/lib/arel/nodes/full_outer_join.rb +1 -0
  33. data/lib/arel/nodes/function.rb +1 -0
  34. data/lib/arel/nodes/grouping.rb +1 -0
  35. data/lib/arel/nodes/in.rb +1 -0
  36. data/lib/arel/nodes/infix_operation.rb +1 -0
  37. data/lib/arel/nodes/inner_join.rb +1 -0
  38. data/lib/arel/nodes/insert_statement.rb +1 -0
  39. data/lib/arel/nodes/join_source.rb +1 -0
  40. data/lib/arel/nodes/matches.rb +1 -0
  41. data/lib/arel/nodes/named_function.rb +1 -0
  42. data/lib/arel/nodes/node.rb +1 -0
  43. data/lib/arel/nodes/outer_join.rb +1 -0
  44. data/lib/arel/nodes/over.rb +1 -0
  45. data/lib/arel/nodes/regexp.rb +1 -0
  46. data/lib/arel/nodes/right_outer_join.rb +1 -0
  47. data/lib/arel/nodes/select_core.rb +1 -0
  48. data/lib/arel/nodes/select_statement.rb +1 -0
  49. data/lib/arel/nodes/sql_literal.rb +1 -0
  50. data/lib/arel/nodes/string_join.rb +1 -0
  51. data/lib/arel/nodes/table_alias.rb +1 -0
  52. data/lib/arel/nodes/terminal.rb +1 -0
  53. data/lib/arel/nodes/true.rb +1 -0
  54. data/lib/arel/nodes/unary.rb +1 -0
  55. data/lib/arel/nodes/unary_operation.rb +1 -0
  56. data/lib/arel/nodes/unqualified_column.rb +1 -0
  57. data/lib/arel/nodes/update_statement.rb +1 -0
  58. data/lib/arel/nodes/values.rb +1 -0
  59. data/lib/arel/nodes/window.rb +1 -0
  60. data/lib/arel/nodes/with.rb +1 -0
  61. data/lib/arel/order_predications.rb +1 -0
  62. data/lib/arel/predications.rb +1 -0
  63. data/lib/arel/select_manager.rb +2 -1
  64. data/lib/arel/table.rb +2 -13
  65. data/lib/arel/tree_manager.rb +1 -0
  66. data/lib/arel/update_manager.rb +1 -0
  67. data/lib/arel/visitors.rb +1 -0
  68. data/lib/arel/visitors/bind_substitute.rb +1 -0
  69. data/lib/arel/visitors/bind_visitor.rb +1 -0
  70. data/lib/arel/visitors/depth_first.rb +1 -0
  71. data/lib/arel/visitors/dot.rb +2 -1
  72. data/lib/arel/visitors/ibm_db.rb +1 -0
  73. data/lib/arel/visitors/informix.rb +1 -0
  74. data/lib/arel/visitors/mssql.rb +1 -0
  75. data/lib/arel/visitors/mysql.rb +1 -0
  76. data/lib/arel/visitors/oracle.rb +2 -1
  77. data/lib/arel/visitors/oracle12.rb +1 -0
  78. data/lib/arel/visitors/postgresql.rb +1 -0
  79. data/lib/arel/visitors/reduce.rb +1 -0
  80. data/lib/arel/visitors/sqlite.rb +1 -0
  81. data/lib/arel/visitors/to_sql.rb +11 -49
  82. data/lib/arel/visitors/visitor.rb +1 -0
  83. data/lib/arel/visitors/where_sql.rb +1 -0
  84. data/lib/arel/window_predications.rb +1 -0
  85. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1986f950d2ecce6990d5a420c7963c874bcf22b
4
- data.tar.gz: e21fbc532cdf9feceed6883a9ed1a151c0c1ebb3
3
+ metadata.gz: d63929355e39f8b80a24e91781752eb2b152ff56
4
+ data.tar.gz: 5c67efb970c72f38f5d43619c52492f77af5f107
5
5
  SHA512:
6
- metadata.gz: c0c67c17600ee4a7ce861bc688abf8d409d8b8c1c65969f26a9cfe8d7263eacd3c50f3e9548b80f1e071cd14e176e765addba6ec84de579c4797a123c960e2b1
7
- data.tar.gz: a9f11f32f1868a9df3b27c88828513bf4106fcce946defc2d383488ab9fe9cb814408c51071ce6bbfe5aa8777d1a1fba7afd4fea89d4931282a2d7447343588e
6
+ metadata.gz: 690294ba02d8416fa6204ec94a2a35d822aa3533d7767e5477da68572ca233cda12eae57eb6d1b4d619afc08e0ff29fc4f09b93a79fae8b83d4778cb351fbc3e
7
+ data.tar.gz: 6bb11f371d17dfc7ffb400e98b49ddad92b80f7095d8e4ff7e72a9c8555c0335f3da6ae08df96cc3641cd8784ea2fea11daaf5fc4b1c860df43eb011023ef18f
@@ -1,29 +1,15 @@
1
- === 7.1.4 / 2016-10-10
1
+ === 8.0.0 / 2017-02-21
2
2
 
3
- * bug fixes
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
- * Don't store all aliases to a table
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
- * bug fixes
10
+ * Bug Fixes
25
11
 
26
- * fix warning in `casted#hash`
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:
@@ -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 = '7.1.4'
27
+ VERSION = '8.0.0'
25
28
 
26
29
  def self.sql raw_sql
27
30
  Arel::Nodes::SqlLiteral.new raw_sql
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module AliasPredication
3
4
  def as other
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'arel/attributes/attribute'
2
3
 
3
4
  module Arel
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Attributes
3
4
  class Attribute < Struct.new :relation, :name
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Collectors
3
4
  class Bind
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Collectors
3
4
  class PlainString
4
5
  def initialize
5
- @str = ''
6
+ @str = ''.dup
6
7
  end
7
8
 
8
9
  def value
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'arel/collectors/plain_string'
4
5
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Compatibility # :nodoc:
3
4
  class Wheres # :nodoc:
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  ###
3
4
  # FIXME hopefully we can remove this
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  class DeleteManager < Arel::TreeManager
3
4
  def initialize
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ module Arel
3
+ class ArelError < StandardError
4
+ end
5
+
6
+ class EmptyJoinError < ArelError
7
+ end
8
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Expressions
3
4
  def count distinct = false
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  ###
3
4
  # Methods for creating various nodes
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  class InsertManager < Arel::TreeManager
3
4
  def initialize
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Math
3
4
  def *(other)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # node
2
3
  require 'arel/nodes/node'
3
4
  require 'arel/nodes/select_statement'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class And < Arel::Nodes::Node
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class Ascending < Ordering
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class Binary < Arel::Nodes::Node
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class BindParam < Node
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class Case < Arel::Nodes::Node
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class Casted < Arel::Nodes::Node # :nodoc:
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class Count < Arel::Nodes::Function
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class DeleteStatement < Arel::Nodes::Binary
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class Descending < Ordering
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class Equality < Arel::Nodes::Binary
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class Extract < Arel::Nodes::Unary
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class False < Arel::Nodes::Node
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class FullOuterJoin < Arel::Nodes::Join
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class Function < Arel::Nodes::Node
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class Grouping < Unary
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class In < Equality
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class InnerJoin < Arel::Nodes::Join
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class InsertStatement < Arel::Nodes::Node
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  ###
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class Matches < Binary
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class NamedFunction < Arel::Nodes::Function
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'arel/collectors/sql_string'
2
3
 
3
4
  module Arel
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class OuterJoin < Arel::Nodes::Join
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class Regexp < Binary
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class RightOuterJoin < Arel::Nodes::Join
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class SelectCore < Arel::Nodes::Node
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class SelectStatement < Arel::Nodes::Node
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class SqlLiteral < String
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class StringJoin < Arel::Nodes::Join
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class TableAlias < Arel::Nodes::Binary
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class Distinct < Arel::Nodes::Node
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class True < Arel::Nodes::Node
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class Unary < Arel::Nodes::Node
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class UnqualifiedColumn < Arel::Nodes::Unary
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class UpdateStatement < Arel::Nodes::Node
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class Values < Arel::Nodes::Binary
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class Window < Arel::Nodes::Node
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Nodes
3
4
  class With < Arel::Nodes::Unary
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module OrderPredications
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Predications
3
4
  def not_eq other
@@ -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
 
@@ -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
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'arel/collectors/sql_string'
2
3
 
3
4
  module Arel
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  class UpdateManager < Arel::TreeManager
3
4
  def initialize
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'arel/visitors/visitor'
2
3
  require 'arel/visitors/depth_first'
3
4
  require 'arel/visitors/to_sql'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Visitors
3
4
  class BindSubstitute
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Visitors
3
4
  module BindVisitor
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Visitors
3
4
  class DepthFirst < Arel::Visitors::Visitor
@@ -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 << "|<f#{i + 1}>#{quote field}"
281
+ label += "|<f#{i + 1}>#{quote field}"
281
282
  end
282
283
 
283
284
  "#{node.id} [label=\"#{label}\"];"
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Visitors
3
4
  class IBM_DB < Arel::Visitors::ToSql
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Visitors
3
4
  class Informix < Arel::Visitors::ToSql
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Visitors
3
4
  class MSSQL < Arel::Visitors::ToSql
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Visitors
3
4
  class MySQL < Arel::Visitors::ToSql
@@ -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] = '' << part
140
+ array[i] = part.to_s
140
141
  end
141
142
  i += 1 if array[i].count('(') == array[i].count(')')
142
143
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Visitors
3
4
  class Oracle12 < Arel::Visitors::ToSql
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Visitors
3
4
  class PostgreSQL < Arel::Visitors::ToSql
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'arel/visitors/visitor'
2
3
 
3
4
  module Arel
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Visitors
3
4
  class SQLite < Arel::Visitors::ToSql
@@ -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 << ' WHERE '
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.zip(o.columns).each_with_index { |(value, attr), i|
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, attr && column_for(attr)).to_s
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, column_for(o.left)).to_s
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, column_for(a))
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, column = nil
774
+ def quote value
796
775
  return value if Arel::Nodes::SqlLiteral === value
797
- if column
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
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Visitors
3
4
  class Visitor
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module Visitors
3
4
  class WhereSql < Arel::Visitors::ToSql
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Arel
2
3
  module WindowPredications
3
4
 
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: 7.1.4
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: 2016-10-10 00:00:00.000000000 Z
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.5.1
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