activerecord 6.0.0.beta1 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activerecord might be problematic. Click here for more details.

Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +455 -9
  3. data/README.rdoc +3 -1
  4. data/lib/active_record/associations/association.rb +18 -1
  5. data/lib/active_record/associations/builder/association.rb +14 -18
  6. data/lib/active_record/associations/builder/belongs_to.rb +5 -2
  7. data/lib/active_record/associations/builder/collection_association.rb +5 -15
  8. data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +1 -1
  9. data/lib/active_record/associations/builder/has_many.rb +2 -0
  10. data/lib/active_record/associations/builder/has_one.rb +35 -1
  11. data/lib/active_record/associations/builder/singular_association.rb +2 -0
  12. data/lib/active_record/associations/collection_association.rb +5 -6
  13. data/lib/active_record/associations/collection_proxy.rb +13 -42
  14. data/lib/active_record/associations/has_many_association.rb +1 -9
  15. data/lib/active_record/associations/has_many_through_association.rb +4 -11
  16. data/lib/active_record/associations/join_dependency/join_association.rb +21 -7
  17. data/lib/active_record/associations/join_dependency.rb +10 -9
  18. data/lib/active_record/associations/preloader/association.rb +37 -34
  19. data/lib/active_record/associations/preloader/through_association.rb +48 -39
  20. data/lib/active_record/associations/preloader.rb +11 -6
  21. data/lib/active_record/associations.rb +3 -2
  22. data/lib/active_record/attribute_methods/before_type_cast.rb +4 -1
  23. data/lib/active_record/attribute_methods/dirty.rb +47 -14
  24. data/lib/active_record/attribute_methods/primary_key.rb +7 -15
  25. data/lib/active_record/attribute_methods/query.rb +2 -3
  26. data/lib/active_record/attribute_methods/read.rb +3 -9
  27. data/lib/active_record/attribute_methods/write.rb +6 -12
  28. data/lib/active_record/attribute_methods.rb +3 -53
  29. data/lib/active_record/attributes.rb +13 -0
  30. data/lib/active_record/autosave_association.rb +15 -5
  31. data/lib/active_record/base.rb +0 -1
  32. data/lib/active_record/callbacks.rb +3 -3
  33. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +124 -23
  34. data/lib/active_record/connection_adapters/abstract/database_limits.rb +8 -4
  35. data/lib/active_record/connection_adapters/abstract/database_statements.rb +101 -70
  36. data/lib/active_record/connection_adapters/abstract/query_cache.rb +11 -5
  37. data/lib/active_record/connection_adapters/abstract/quoting.rb +63 -6
  38. data/lib/active_record/connection_adapters/abstract/schema_creation.rb +5 -2
  39. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +51 -40
  40. data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +1 -1
  41. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +95 -30
  42. data/lib/active_record/connection_adapters/abstract/transaction.rb +17 -6
  43. data/lib/active_record/connection_adapters/abstract_adapter.rb +108 -39
  44. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +93 -134
  45. data/lib/active_record/connection_adapters/column.rb +17 -13
  46. data/lib/active_record/connection_adapters/connection_specification.rb +1 -1
  47. data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +3 -3
  48. data/lib/active_record/connection_adapters/mysql/database_statements.rb +45 -7
  49. data/lib/active_record/connection_adapters/mysql/quoting.rb +44 -7
  50. data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +40 -32
  51. data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +14 -6
  52. data/lib/active_record/connection_adapters/mysql/schema_statements.rb +66 -5
  53. data/lib/active_record/connection_adapters/mysql/type_metadata.rb +6 -10
  54. data/lib/active_record/connection_adapters/mysql2_adapter.rb +18 -5
  55. data/lib/active_record/connection_adapters/postgresql/column.rb +17 -30
  56. data/lib/active_record/connection_adapters/postgresql/database_statements.rb +5 -1
  57. data/lib/active_record/connection_adapters/postgresql/oid/money.rb +2 -2
  58. data/lib/active_record/connection_adapters/postgresql/oid/range.rb +1 -1
  59. data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +6 -3
  60. data/lib/active_record/connection_adapters/postgresql/quoting.rb +40 -3
  61. data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +36 -0
  62. data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +98 -89
  63. data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +47 -63
  64. data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +23 -27
  65. data/lib/active_record/connection_adapters/postgresql_adapter.rb +91 -24
  66. data/lib/active_record/connection_adapters/schema_cache.rb +32 -14
  67. data/lib/active_record/connection_adapters/sql_type_metadata.rb +11 -8
  68. data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +118 -0
  69. data/lib/active_record/connection_adapters/sqlite3/quoting.rb +38 -2
  70. data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +28 -2
  71. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +69 -118
  72. data/lib/active_record/connection_handling.rb +32 -16
  73. data/lib/active_record/core.rb +27 -20
  74. data/lib/active_record/database_configurations/hash_config.rb +11 -11
  75. data/lib/active_record/database_configurations/url_config.rb +21 -16
  76. data/lib/active_record/database_configurations.rb +99 -50
  77. data/lib/active_record/dynamic_matchers.rb +1 -1
  78. data/lib/active_record/enum.rb +15 -0
  79. data/lib/active_record/errors.rb +18 -13
  80. data/lib/active_record/fixtures.rb +11 -6
  81. data/lib/active_record/gem_version.rb +1 -1
  82. data/lib/active_record/inheritance.rb +1 -1
  83. data/lib/active_record/insert_all.rb +179 -0
  84. data/lib/active_record/integration.rb +13 -1
  85. data/lib/active_record/internal_metadata.rb +5 -1
  86. data/lib/active_record/locking/optimistic.rb +3 -4
  87. data/lib/active_record/log_subscriber.rb +1 -1
  88. data/lib/active_record/middleware/database_selector/resolver/session.rb +45 -0
  89. data/lib/active_record/middleware/database_selector/resolver.rb +92 -0
  90. data/lib/active_record/middleware/database_selector.rb +75 -0
  91. data/lib/active_record/migration/command_recorder.rb +28 -14
  92. data/lib/active_record/migration/compatibility.rb +72 -63
  93. data/lib/active_record/migration.rb +62 -44
  94. data/lib/active_record/persistence.rb +212 -19
  95. data/lib/active_record/querying.rb +18 -14
  96. data/lib/active_record/railtie.rb +9 -1
  97. data/lib/active_record/railties/collection_cache_association_loading.rb +3 -3
  98. data/lib/active_record/railties/databases.rake +124 -25
  99. data/lib/active_record/reflection.rb +18 -32
  100. data/lib/active_record/relation/calculations.rb +40 -44
  101. data/lib/active_record/relation/delegation.rb +23 -31
  102. data/lib/active_record/relation/finder_methods.rb +13 -13
  103. data/lib/active_record/relation/merger.rb +11 -16
  104. data/lib/active_record/relation/query_attribute.rb +5 -3
  105. data/lib/active_record/relation/query_methods.rb +217 -68
  106. data/lib/active_record/relation/spawn_methods.rb +1 -1
  107. data/lib/active_record/relation/where_clause.rb +10 -10
  108. data/lib/active_record/relation.rb +184 -35
  109. data/lib/active_record/sanitization.rb +33 -4
  110. data/lib/active_record/schema.rb +1 -1
  111. data/lib/active_record/schema_dumper.rb +10 -1
  112. data/lib/active_record/schema_migration.rb +1 -1
  113. data/lib/active_record/scoping/default.rb +7 -15
  114. data/lib/active_record/scoping/named.rb +10 -2
  115. data/lib/active_record/scoping.rb +6 -7
  116. data/lib/active_record/statement_cache.rb +2 -2
  117. data/lib/active_record/store.rb +48 -0
  118. data/lib/active_record/table_metadata.rb +9 -13
  119. data/lib/active_record/tasks/database_tasks.rb +109 -6
  120. data/lib/active_record/tasks/mysql_database_tasks.rb +3 -1
  121. data/lib/active_record/test_databases.rb +1 -16
  122. data/lib/active_record/test_fixtures.rb +2 -2
  123. data/lib/active_record/timestamp.rb +35 -19
  124. data/lib/active_record/touch_later.rb +4 -2
  125. data/lib/active_record/transactions.rb +55 -45
  126. data/lib/active_record/type_caster/connection.rb +16 -10
  127. data/lib/active_record/validations/uniqueness.rb +4 -4
  128. data/lib/active_record/validations.rb +1 -0
  129. data/lib/active_record.rb +7 -1
  130. data/lib/arel/insert_manager.rb +3 -3
  131. data/lib/arel/nodes/and.rb +1 -1
  132. data/lib/arel/nodes/case.rb +1 -1
  133. data/lib/arel/nodes/comment.rb +29 -0
  134. data/lib/arel/nodes/select_core.rb +16 -12
  135. data/lib/arel/nodes/unary.rb +1 -0
  136. data/lib/arel/nodes/values_list.rb +2 -17
  137. data/lib/arel/nodes.rb +2 -1
  138. data/lib/arel/select_manager.rb +10 -10
  139. data/lib/arel/visitors/depth_first.rb +7 -2
  140. data/lib/arel/visitors/dot.rb +7 -2
  141. data/lib/arel/visitors/ibm_db.rb +13 -0
  142. data/lib/arel/visitors/informix.rb +6 -0
  143. data/lib/arel/visitors/mssql.rb +15 -1
  144. data/lib/arel/visitors/oracle12.rb +4 -5
  145. data/lib/arel/visitors/postgresql.rb +4 -10
  146. data/lib/arel/visitors/to_sql.rb +107 -131
  147. data/lib/arel/visitors/visitor.rb +9 -5
  148. data/lib/arel.rb +7 -0
  149. data/lib/rails/generators/active_record/migration/migration_generator.rb +1 -1
  150. data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb.tt +1 -1
  151. data/lib/rails/generators/active_record/migration/templates/migration.rb.tt +4 -2
  152. data/lib/rails/generators/active_record/model/model_generator.rb +1 -1
  153. data/lib/rails/generators/active_record/model/templates/model.rb.tt +10 -1
  154. metadata +17 -13
  155. data/lib/active_record/collection_cache_key.rb +0 -53
  156. data/lib/arel/nodes/values.rb +0 -16
data/lib/active_record.rb CHANGED
@@ -55,7 +55,6 @@ module ActiveRecord
55
55
  autoload :Persistence
56
56
  autoload :QueryCache
57
57
  autoload :Querying
58
- autoload :CollectionCacheKey
59
58
  autoload :ReadonlyAttributes
60
59
  autoload :RecordInvalid, "active_record/validations"
61
60
  autoload :Reflection
@@ -74,6 +73,7 @@ module ActiveRecord
74
73
  autoload :Translation
75
74
  autoload :Validations
76
75
  autoload :SecureToken
76
+ autoload :DatabaseSelector, "active_record/middleware/database_selector"
77
77
 
78
78
  eager_autoload do
79
79
  autoload :ActiveRecordError, "active_record/errors"
@@ -153,6 +153,12 @@ module ActiveRecord
153
153
  end
154
154
  end
155
155
 
156
+ module Middleware
157
+ extend ActiveSupport::Autoload
158
+
159
+ autoload :DatabaseSelector, "active_record/middleware/database_selector"
160
+ end
161
+
156
162
  module Tasks
157
163
  extend ActiveSupport::Autoload
158
164
 
@@ -33,13 +33,13 @@ module Arel # :nodoc: all
33
33
  @ast.columns << column
34
34
  values << value
35
35
  end
36
- @ast.values = create_values values, @ast.columns
36
+ @ast.values = create_values(values)
37
37
  end
38
38
  self
39
39
  end
40
40
 
41
- def create_values(values, columns)
42
- Nodes::Values.new values, columns
41
+ def create_values(values)
42
+ Nodes::ValuesList.new([values])
43
43
  end
44
44
 
45
45
  def create_values_list(rows)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Arel # :nodoc: all
4
4
  module Nodes
5
- class And < Arel::Nodes::Node
5
+ class And < Arel::Nodes::NodeExpression
6
6
  attr_reader :children
7
7
 
8
8
  def initialize(children)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Arel # :nodoc: all
4
4
  module Nodes
5
- class Case < Arel::Nodes::Node
5
+ class Case < Arel::Nodes::NodeExpression
6
6
  attr_accessor :case, :conditions, :default
7
7
 
8
8
  def initialize(expression = nil, default = nil)
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Arel # :nodoc: all
4
+ module Nodes
5
+ class Comment < Arel::Nodes::Node
6
+ attr_reader :values
7
+
8
+ def initialize(values)
9
+ super()
10
+ @values = values
11
+ end
12
+
13
+ def initialize_copy(other)
14
+ super
15
+ @values = @values.clone
16
+ end
17
+
18
+ def hash
19
+ [@values].hash
20
+ end
21
+
22
+ def eql?(other)
23
+ self.class == other.class &&
24
+ self.values == other.values
25
+ end
26
+ alias :== :eql?
27
+ end
28
+ end
29
+ end
@@ -3,20 +3,22 @@
3
3
  module Arel # :nodoc: all
4
4
  module Nodes
5
5
  class SelectCore < Arel::Nodes::Node
6
- attr_accessor :projections, :wheres, :groups, :windows
7
- attr_accessor :havings, :source, :set_quantifier
6
+ attr_accessor :projections, :wheres, :groups, :windows, :comment
7
+ attr_accessor :havings, :source, :set_quantifier, :optimizer_hints
8
8
 
9
9
  def initialize
10
10
  super()
11
- @source = JoinSource.new nil
11
+ @source = JoinSource.new nil
12
12
 
13
13
  # https://ronsavage.github.io/SQL/sql-92.bnf.html#set%20quantifier
14
- @set_quantifier = nil
15
- @projections = []
16
- @wheres = []
17
- @groups = []
18
- @havings = []
19
- @windows = []
14
+ @set_quantifier = nil
15
+ @optimizer_hints = nil
16
+ @projections = []
17
+ @wheres = []
18
+ @groups = []
19
+ @havings = []
20
+ @windows = []
21
+ @comment = nil
20
22
  end
21
23
 
22
24
  def from
@@ -42,8 +44,8 @@ module Arel # :nodoc: all
42
44
 
43
45
  def hash
44
46
  [
45
- @source, @set_quantifier, @projections,
46
- @wheres, @groups, @havings, @windows
47
+ @source, @set_quantifier, @projections, @optimizer_hints,
48
+ @wheres, @groups, @havings, @windows, @comment
47
49
  ].hash
48
50
  end
49
51
 
@@ -51,11 +53,13 @@ module Arel # :nodoc: all
51
53
  self.class == other.class &&
52
54
  self.source == other.source &&
53
55
  self.set_quantifier == other.set_quantifier &&
56
+ self.optimizer_hints == other.optimizer_hints &&
54
57
  self.projections == other.projections &&
55
58
  self.wheres == other.wheres &&
56
59
  self.groups == other.groups &&
57
60
  self.havings == other.havings &&
58
- self.windows == other.windows
61
+ self.windows == other.windows &&
62
+ self.comment == other.comment
59
63
  end
60
64
  alias :== :eql?
61
65
  end
@@ -35,6 +35,7 @@ module Arel # :nodoc: all
35
35
  Not
36
36
  Offset
37
37
  On
38
+ OptimizerHints
38
39
  Ordering
39
40
  RollUp
40
41
  }.each do |name|
@@ -2,23 +2,8 @@
2
2
 
3
3
  module Arel # :nodoc: all
4
4
  module Nodes
5
- class ValuesList < Node
6
- attr_reader :rows
7
-
8
- def initialize(rows)
9
- @rows = rows
10
- super()
11
- end
12
-
13
- def hash
14
- @rows.hash
15
- end
16
-
17
- def eql?(other)
18
- self.class == other.class &&
19
- self.rows == other.rows
20
- end
21
- alias :== :eql?
5
+ class ValuesList < Unary
6
+ alias :rows :expr
22
7
  end
23
8
  end
24
9
  end
data/lib/arel/nodes.rb CHANGED
@@ -45,7 +45,6 @@ require "arel/nodes/and"
45
45
  require "arel/nodes/function"
46
46
  require "arel/nodes/count"
47
47
  require "arel/nodes/extract"
48
- require "arel/nodes/values"
49
48
  require "arel/nodes/values_list"
50
49
  require "arel/nodes/named_function"
51
50
 
@@ -62,6 +61,8 @@ require "arel/nodes/outer_join"
62
61
  require "arel/nodes/right_outer_join"
63
62
  require "arel/nodes/string_join"
64
63
 
64
+ require "arel/nodes/comment"
65
+
65
66
  require "arel/nodes/sql_literal"
66
67
 
67
68
  require "arel/nodes/casted"
@@ -146,6 +146,13 @@ module Arel # :nodoc: all
146
146
  @ctx.projections = projections
147
147
  end
148
148
 
149
+ def optimizer_hints(*hints)
150
+ unless hints.empty?
151
+ @ctx.optimizer_hints = Arel::Nodes::OptimizerHints.new(hints)
152
+ end
153
+ self
154
+ end
155
+
149
156
  def distinct(value = true)
150
157
  if value
151
158
  @ctx.set_quantifier = Arel::Nodes::Distinct.new
@@ -237,16 +244,9 @@ module Arel # :nodoc: all
237
244
  @ctx.source
238
245
  end
239
246
 
240
- class Row < Struct.new(:data) # :nodoc:
241
- def id
242
- data["id"]
243
- end
244
-
245
- def method_missing(name, *args)
246
- name = name.to_s
247
- return data[name] if data.key?(name)
248
- super
249
- end
247
+ def comment(*values)
248
+ @ctx.comment = Nodes::Comment.new(values)
249
+ self
250
250
  end
251
251
 
252
252
  private
@@ -10,7 +10,7 @@ module Arel # :nodoc: all
10
10
 
11
11
  private
12
12
 
13
- def visit(o)
13
+ def visit(o, _ = nil)
14
14
  super
15
15
  @block.call o
16
16
  end
@@ -35,6 +35,8 @@ module Arel # :nodoc: all
35
35
  alias :visit_Arel_Nodes_Ascending :unary
36
36
  alias :visit_Arel_Nodes_Descending :unary
37
37
  alias :visit_Arel_Nodes_UnqualifiedColumn :unary
38
+ alias :visit_Arel_Nodes_OptimizerHints :unary
39
+ alias :visit_Arel_Nodes_ValuesList :unary
38
40
 
39
41
  def function(o)
40
42
  visit o.expressions
@@ -102,7 +104,6 @@ module Arel # :nodoc: all
102
104
  alias :visit_Arel_Nodes_Regexp :binary
103
105
  alias :visit_Arel_Nodes_RightOuterJoin :binary
104
106
  alias :visit_Arel_Nodes_TableAlias :binary
105
- alias :visit_Arel_Nodes_Values :binary
106
107
  alias :visit_Arel_Nodes_When :binary
107
108
 
108
109
  def visit_Arel_Nodes_StringJoin(o)
@@ -180,6 +181,10 @@ module Arel # :nodoc: all
180
181
  visit o.limit
181
182
  end
182
183
 
184
+ def visit_Arel_Nodes_Comment(o)
185
+ visit o.values
186
+ end
187
+
183
188
  def visit_Array(o)
184
189
  o.each { |i| visit i }
185
190
  end
@@ -46,8 +46,8 @@ module Arel # :nodoc: all
46
46
  visit_edge o, "distinct"
47
47
  end
48
48
 
49
- def visit_Arel_Nodes_Values(o)
50
- visit_edge o, "expressions"
49
+ def visit_Arel_Nodes_ValuesList(o)
50
+ visit_edge o, "rows"
51
51
  end
52
52
 
53
53
  def visit_Arel_Nodes_StringJoin(o)
@@ -82,6 +82,7 @@ module Arel # :nodoc: all
82
82
  alias :visit_Arel_Nodes_Offset :unary
83
83
  alias :visit_Arel_Nodes_On :unary
84
84
  alias :visit_Arel_Nodes_UnqualifiedColumn :unary
85
+ alias :visit_Arel_Nodes_OptimizerHints :unary
85
86
  alias :visit_Arel_Nodes_Preceding :unary
86
87
  alias :visit_Arel_Nodes_Following :unary
87
88
  alias :visit_Arel_Nodes_Rows :unary
@@ -233,6 +234,10 @@ module Arel # :nodoc: all
233
234
  end
234
235
  alias :visit_Set :visit_Array
235
236
 
237
+ def visit_Arel_Nodes_Comment(o)
238
+ visit_edge(o, "values")
239
+ end
240
+
236
241
  def visit_edge(o, method)
237
242
  edge(method) { visit o.send(method) }
238
243
  end
@@ -4,6 +4,15 @@ module Arel # :nodoc: all
4
4
  module Visitors
5
5
  class IBM_DB < Arel::Visitors::ToSql
6
6
  private
7
+ def visit_Arel_Nodes_SelectCore(o, collector)
8
+ collector = super
9
+ maybe_visit o.optimizer_hints, collector
10
+ end
11
+
12
+ def visit_Arel_Nodes_OptimizerHints(o, collector)
13
+ hints = o.expr.map { |v| sanitize_as_sql_comment(v) }.join
14
+ collector << "/* <OPTGUIDELINES>#{hints}</OPTGUIDELINES> */"
15
+ end
7
16
 
8
17
  def visit_Arel_Nodes_Limit(o, collector)
9
18
  collector << "FETCH FIRST "
@@ -16,6 +25,10 @@ module Arel # :nodoc: all
16
25
  collector = visit [o.left, o.right, 0, 1], collector
17
26
  collector << ")"
18
27
  end
28
+
29
+ def collect_optimizer_hints(o, collector)
30
+ collector
31
+ end
19
32
  end
20
33
  end
21
34
  end
@@ -42,10 +42,16 @@ module Arel # :nodoc: all
42
42
  collector
43
43
  end
44
44
 
45
+ def visit_Arel_Nodes_OptimizerHints(o, collector)
46
+ hints = o.expr.map { |v| sanitize_as_sql_comment(v) }.join(", ")
47
+ collector << "/*+ #{hints} */"
48
+ end
49
+
45
50
  def visit_Arel_Nodes_Offset(o, collector)
46
51
  collector << "SKIP "
47
52
  visit o.expr, collector
48
53
  end
54
+
49
55
  def visit_Arel_Nodes_Limit(o, collector)
50
56
  collector << "FIRST "
51
57
  visit o.expr, collector
@@ -76,6 +76,16 @@ module Arel # :nodoc: all
76
76
  end
77
77
  end
78
78
 
79
+ def visit_Arel_Nodes_SelectCore(o, collector)
80
+ collector = super
81
+ maybe_visit o.optimizer_hints, collector
82
+ end
83
+
84
+ def visit_Arel_Nodes_OptimizerHints(o, collector)
85
+ hints = o.expr.map { |v| sanitize_as_sql_comment(v) }.join(", ")
86
+ collector << "OPTION (#{hints})"
87
+ end
88
+
79
89
  def get_offset_limit_clause(o)
80
90
  first_row = o.offset ? o.offset.expr.to_i + 1 : 1
81
91
  last_row = o.limit ? o.limit.expr.to_i - 1 + first_row : nil
@@ -97,12 +107,16 @@ module Arel # :nodoc: all
97
107
  collector = visit o.relation, collector
98
108
  if o.wheres.any?
99
109
  collector << " WHERE "
100
- inject_join o.wheres, collector, AND
110
+ inject_join o.wheres, collector, " AND "
101
111
  else
102
112
  collector
103
113
  end
104
114
  end
105
115
 
116
+ def collect_optimizer_hints(o, collector)
117
+ collector
118
+ end
119
+
106
120
  def determine_order_by(orders, x)
107
121
  if orders.any?
108
122
  orders
@@ -8,11 +8,10 @@ module Arel # :nodoc: all
8
8
  def visit_Arel_Nodes_SelectStatement(o, collector)
9
9
  # Oracle does not allow LIMIT clause with select for update
10
10
  if o.limit && o.lock
11
- raise ArgumentError, <<-MSG
12
- 'Combination of limit and lock is not supported.
13
- because generated SQL statements
14
- `SELECT FOR UPDATE and FETCH FIRST n ROWS` generates ORA-02014.`
15
- MSG
11
+ raise ArgumentError, <<~MSG
12
+ Combination of limit and lock is not supported. Because generated SQL statements
13
+ `SELECT FOR UPDATE and FETCH FIRST n ROWS` generates ORA-02014.
14
+ MSG
16
15
  end
17
16
  super
18
17
  end
@@ -3,11 +3,6 @@
3
3
  module Arel # :nodoc: all
4
4
  module Visitors
5
5
  class PostgreSQL < Arel::Visitors::ToSql
6
- CUBE = "CUBE"
7
- ROLLUP = "ROLLUP"
8
- GROUPING_SETS = "GROUPING SETS"
9
- LATERAL = "LATERAL"
10
-
11
6
  private
12
7
 
13
8
  def visit_Arel_Nodes_Matches(o, collector)
@@ -57,23 +52,22 @@ module Arel # :nodoc: all
57
52
  end
58
53
 
59
54
  def visit_Arel_Nodes_Cube(o, collector)
60
- collector << CUBE
55
+ collector << "CUBE"
61
56
  grouping_array_or_grouping_element o, collector
62
57
  end
63
58
 
64
59
  def visit_Arel_Nodes_RollUp(o, collector)
65
- collector << ROLLUP
60
+ collector << "ROLLUP"
66
61
  grouping_array_or_grouping_element o, collector
67
62
  end
68
63
 
69
64
  def visit_Arel_Nodes_GroupingSet(o, collector)
70
- collector << GROUPING_SETS
65
+ collector << "GROUPING SETS"
71
66
  grouping_array_or_grouping_element o, collector
72
67
  end
73
68
 
74
69
  def visit_Arel_Nodes_Lateral(o, collector)
75
- collector << LATERAL
76
- collector << SPACE
70
+ collector << "LATERAL "
77
71
  grouping_parentheses o, collector
78
72
  end
79
73