activerecord 4.2.7.1 → 4.2.8.rc1

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b27166a8cdbbc938588145984ecc536905ea7b49
4
- data.tar.gz: b835c5264868bb6df623a97c7d8cdab457fe35c8
3
+ metadata.gz: 7354a19acea0291b17f2dc0f4461d9168a4ce4e4
4
+ data.tar.gz: 175ee018440a7a47aa915b2a4568db0fc23e0e15
5
5
  SHA512:
6
- metadata.gz: aa5ca2a1f3553ed395014a4c8808838dca260cec90266dc5dda61f4c8c4f5d4bc659ead3c4af9189555a96e87d4b053dcc04c8e5aae09744e4a4a0c14c57bb20
7
- data.tar.gz: d9733d5c9e015373b0101299215f411cdc5dff68a961c307fe0336a5daa83bfa7992abe6266a43cb35690853f9df84921ee215ae54cfaf3baa2032aacc081418
6
+ metadata.gz: 8326290b48e0607c91e088535bcfcc395309a3eedce5679933f4232ffe0808027e7d2c728be46cbbcb3425898a1651141b93dd0e6ea0ca8df00ad037e801b111
7
+ data.tar.gz: '09429829149e69921ff2f262d719b4a7570e47d4e4dd5c3d25d68320ee540420196fb5a30faa237d723b05d6b0a448701cbe531d05e11b9f1ce24e8d2d6048cf'
@@ -1,3 +1,34 @@
1
+ ## Rails 4.2.8.rc1 (February 09, 2017) ##
2
+
3
+ * Using a mysql2 connection after it fails to reconnect will now have an error message
4
+ saying the connection is closed rather than an undefined method error message.
5
+
6
+ *Dylan Thacker-Smith*
7
+
8
+ * Bust Model.attribute_names cache when resetting column information
9
+
10
+ *James Coleman*
11
+
12
+ * Fix query caching when type information is reset
13
+
14
+ Backports ancillary fix in 5.0.
15
+
16
+ *James Coleman*
17
+
18
+ * Allow `joins` to be unscoped.
19
+
20
+ Fixes #13775.
21
+
22
+ *Takashi Kokubun*
23
+
24
+ * Hashes can once again be passed to setters of `composed_of`, if all of the
25
+ mapping methods are methods implemented on `Hash`.
26
+
27
+ Fixes #25978.
28
+
29
+ *Sean Griffin*
30
+
31
+
1
32
  ## Rails 4.2.7 (July 12, 2016) ##
2
33
 
3
34
  * Inspecting an object with an associated array of over 10 elements no longer
@@ -43,7 +43,6 @@ module ActiveRecord
43
43
  autoload :Explain
44
44
  autoload :Inheritance
45
45
  autoload :Integration
46
- autoload :LegacyYamlAdapter
47
46
  autoload :Migration
48
47
  autoload :Migrator, 'active_record/migration'
49
48
  autoload :ModelSchema
@@ -80,6 +79,8 @@ module ActiveRecord
80
79
  autoload :AttributeMethods
81
80
  autoload :AutosaveAssociation
82
81
 
82
+ autoload :LegacyYamlAdapter
83
+
83
84
  autoload :Relation
84
85
  autoload :AssociationRelation
85
86
  autoload :NullRelation
@@ -249,7 +249,9 @@ module ActiveRecord
249
249
  part = converter.respond_to?(:call) ? converter.call(part) : klass.send(converter, part)
250
250
  end
251
251
 
252
- if part.is_a?(Hash)
252
+ hash_from_multiparameter_assignment = part.is_a?(Hash) &&
253
+ part.each_key.all? { |k| k.is_a?(Integer) }
254
+ if hash_from_multiparameter_assignment
253
255
  part = klass.new(*part.values)
254
256
  end
255
257
 
@@ -61,10 +61,17 @@ module ActiveRecord
61
61
 
62
62
  # Implements the ids writer method, e.g. foo.item_ids= for Foo.has_many :items
63
63
  def ids_writer(ids)
64
- pk_type = reflection.primary_key_type
65
- ids = Array(ids).reject { |id| id.blank? }
66
- ids.map! { |i| pk_type.type_cast_from_user(i) }
67
- replace(klass.find(ids).index_by { |r| r.id }.values_at(*ids))
64
+ pk_column = reflection.association_primary_key
65
+ pk_type = klass.type_for_attribute(pk_column)
66
+ ids = Array(ids).reject(&:blank?).map do |i|
67
+ pk_type.type_cast_from_user(i)
68
+ end
69
+
70
+ if (objs = klass.where(pk_column => ids)).size == ids.size
71
+ replace(objs.index_by { |r| r.send(pk_column) }.values_at(*ids))
72
+ else
73
+ objs.raise_record_not_found_exception!(ids, objs.size, ids.size)
74
+ end
68
75
  end
69
76
 
70
77
  def reset
@@ -264,7 +271,7 @@ module ActiveRecord
264
271
  _options = records.extract_options!
265
272
  dependent = _options[:dependent] || options[:dependent]
266
273
 
267
- records = find(records) if records.any? { |record| record.kind_of?(Fixnum) || record.kind_of?(String) }
274
+ records = find(records) if records.any? { |record| record.kind_of?(Integer) || record.kind_of?(String) }
268
275
  delete_or_destroy(records, dependent)
269
276
  end
270
277
 
@@ -275,7 +282,7 @@ module ActiveRecord
275
282
  # +:dependent+ option.
276
283
  def destroy(*records)
277
284
  return if records.empty?
278
- records = find(records) if records.any? { |record| record.kind_of?(Fixnum) || record.kind_of?(String) }
285
+ records = find(records) if records.any? { |record| record.kind_of?(Integer) || record.kind_of?(String) }
279
286
  delete_or_destroy(records, :destroy)
280
287
  end
281
288
 
@@ -562,7 +562,7 @@ module ActiveRecord
562
562
  # Pet.find(1)
563
563
  # # => ActiveRecord::RecordNotFound: Couldn't find Pet with id=1
564
564
  #
565
- # You can pass +Fixnum+ or +String+ values, it finds the records
565
+ # You can pass +Integer+ or +String+ values, it finds the records
566
566
  # responding to the +id+ and executes delete on them.
567
567
  #
568
568
  # class Person < ActiveRecord::Base
@@ -626,7 +626,7 @@ module ActiveRecord
626
626
  #
627
627
  # Pet.find(1, 2, 3) # => ActiveRecord::RecordNotFound: Couldn't find all Pets with IDs (1, 2, 3)
628
628
  #
629
- # You can pass +Fixnum+ or +String+ values, it finds the records
629
+ # You can pass +Integer+ or +String+ values, it finds the records
630
630
  # responding to the +id+ and then deletes them from the database.
631
631
  #
632
632
  # person.pets.size # => 3
@@ -52,7 +52,15 @@ module ActiveRecord
52
52
  end
53
53
  scope_chain_index += 1
54
54
 
55
- scope_chain_items.concat [klass.send(:build_default_scope, ActiveRecord::Relation.create(klass, table))].compact
55
+ klass_scope =
56
+ if klass.current_scope
57
+ klass.current_scope.clone.tap { |scope|
58
+ scope.joins_values = []
59
+ }
60
+ else
61
+ klass.send(:build_default_scope, ActiveRecord::Relation.create(klass, table))
62
+ end
63
+ scope_chain_items.concat [klass_scope].compact
56
64
 
57
65
  rel = scope_chain_items.inject(scope_chain_items.shift) do |left, right|
58
66
  left.merge right
@@ -69,7 +69,7 @@ module ActiveRecord
69
69
  # by calling new on the column type or aggregation type (through composed_of) object with these parameters.
70
70
  # So having the pairs written_on(1) = "2004", written_on(2) = "6", written_on(3) = "24", will instantiate
71
71
  # written_on (a date type) with Date.new("2004", "6", "24"). You can also specify a typecast character in the
72
- # parentheses to have the parameters typecasted before they're used in the constructor. Use i for Fixnum and
72
+ # parentheses to have the parameters typecasted before they're used in the constructor. Use i for Integer and
73
73
  # f for Float. If all the values for a given attribute are empty, the attribute will be set to +nil+.
74
74
  def assign_multiparameter_attributes(pairs)
75
75
  execute_callstack_for_multiparameter_attributes(
@@ -364,7 +364,7 @@ module ActiveRecord
364
364
  # person = Person.new
365
365
  # person[:age] = '22'
366
366
  # person[:age] # => 22
367
- # person[:age] # => Fixnum
367
+ # person[:age].class # => Integer
368
368
  def []=(attr_name, value)
369
369
  write_attribute(attr_name, value)
370
370
  end
@@ -50,7 +50,7 @@ module ActiveRecord
50
50
  end
51
51
 
52
52
  # Updates the attribute identified by <tt>attr_name</tt> with the
53
- # specified +value+. Empty strings for fixnum and float columns are
53
+ # specified +value+. Empty strings for Integer and Float columns are
54
54
  # turned into +nil+.
55
55
  def write_attribute(attr_name, value)
56
56
  write_attribute_with_type_cast(attr_name, value, true)
@@ -136,6 +136,7 @@ module ActiveRecord
136
136
  @content_columns = nil
137
137
  @default_attributes = nil
138
138
  @persistable_attribute_names = nil
139
+ @attribute_names = nil
139
140
  end
140
141
 
141
142
  def raw_default_values
@@ -637,7 +637,7 @@ module ActiveRecord
637
637
  end
638
638
 
639
639
  def pool_from_any_process_for(owner)
640
- owner_to_pool = @owner_to_pool.values.find { |v| v[owner.name] }
640
+ owner_to_pool = @owner_to_pool.values.reverse.find { |v| v[owner.name] }
641
641
  owner_to_pool && owner_to_pool[owner.name]
642
642
  end
643
643
  end
@@ -1,4 +1,5 @@
1
1
  require 'active_support/core_ext/big_decimal/conversions'
2
+ require "active_support/multibyte/chars"
2
3
 
3
4
  module ActiveRecord
4
5
  module ConnectionAdapters # :nodoc:
@@ -750,7 +750,7 @@ module ActiveRecord
750
750
  case length
751
751
  when Hash
752
752
  column_names.each {|name| option_strings[name] += "(#{length[name]})" if length.has_key?(name) && length[name].present?}
753
- when Fixnum
753
+ when Integer
754
754
  column_names.each {|name| option_strings[name] += "(#{length})"}
755
755
  end
756
756
  end
@@ -864,7 +864,7 @@ module ActiveRecord
864
864
 
865
865
  # Increase timeout so the server doesn't disconnect us.
866
866
  wait_timeout = @config[:wait_timeout]
867
- wait_timeout = 2147483 unless wait_timeout.is_a?(Fixnum)
867
+ wait_timeout = 2147483 unless wait_timeout.is_a?(Integer)
868
868
  variables['wait_timeout'] = self.class.type_cast_config_to_integer(wait_timeout)
869
869
 
870
870
  # Make MySQL reject illegal values rather than truncating or blanking them, see
@@ -87,7 +87,6 @@ module ActiveRecord
87
87
  #++
88
88
 
89
89
  def active?
90
- return false unless @connection
91
90
  @connection.ping
92
91
  end
93
92
 
@@ -102,10 +101,7 @@ module ActiveRecord
102
101
  # Otherwise, this method does nothing.
103
102
  def disconnect!
104
103
  super
105
- unless @connection.nil?
106
- @connection.close
107
- @connection = nil
108
- end
104
+ @connection.close
109
105
  end
110
106
 
111
107
  #--
@@ -222,11 +218,9 @@ module ActiveRecord
222
218
 
223
219
  # Executes the SQL statement in the context of this connection.
224
220
  def execute(sql, name = nil)
225
- if @connection
226
- # make sure we carry over any changes to ActiveRecord::Base.default_timezone that have been
227
- # made since we established the connection
228
- @connection.query_options[:database_timezone] = ActiveRecord::Base.default_timezone
229
- end
221
+ # make sure we carry over any changes to ActiveRecord::Base.default_timezone that have been
222
+ # made since we established the connection
223
+ @connection.query_options[:database_timezone] = ActiveRecord::Base.default_timezone
230
224
 
231
225
  super
232
226
  end
@@ -80,6 +80,7 @@ module ActiveRecord
80
80
  value
81
81
  end
82
82
  when nil then "NULL"
83
+ when ::Date, ::DateTime, ::Time then subtype.type_cast_for_schema(value)
83
84
  else value
84
85
  end
85
86
  end
@@ -7,8 +7,8 @@ module ActiveRecord
7
7
  module VERSION
8
8
  MAJOR = 4
9
9
  MINOR = 2
10
- TINY = 7
11
- PRE = "1"
10
+ TINY = 8
11
+ PRE = "rc1"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
@@ -247,7 +247,7 @@ module ActiveRecord
247
247
  # Returns a hash where the keys are column names and the values are
248
248
  # default values when instantiating the AR object for this table.
249
249
  def column_defaults
250
- _default_attributes.to_hash
250
+ _default_attributes.dup.to_hash
251
251
  end
252
252
 
253
253
  def _default_attributes # :nodoc:
@@ -94,7 +94,7 @@ module ActiveRecord
94
94
  #
95
95
  # There are two basic forms of output:
96
96
  #
97
- # * Single aggregate value: The single value is type cast to Fixnum for COUNT, Float
97
+ # * Single aggregate value: The single value is type cast to Integer for COUNT, Float
98
98
  # for AVG, and the given column's type for everything else.
99
99
  #
100
100
  # * Grouped values: This returns an ordered hash of the values and groups them. It
@@ -34,10 +34,7 @@ module ActiveRecord
34
34
  end
35
35
 
36
36
  def drop_table
37
- if table_exists?
38
- connection.remove_index table_name, name: index_name
39
- connection.drop_table(table_name)
40
- end
37
+ connection.drop_table table_name if table_exists?
41
38
  end
42
39
 
43
40
  def normalize_migration_number(number)
@@ -86,6 +86,11 @@ module ActiveRecord
86
86
  scale == other.scale &&
87
87
  limit == other.limit
88
88
  end
89
+ alias eql? ==
90
+
91
+ def hash
92
+ [self.class, precision, scale, limit].hash
93
+ end
89
94
 
90
95
  private
91
96
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.7.1
4
+ version: 4.2.8.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-10 00:00:00.000000000 Z
11
+ date: 2017-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.7.1
19
+ version: 4.2.8.rc1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 4.2.7.1
26
+ version: 4.2.8.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activemodel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 4.2.7.1
33
+ version: 4.2.8.rc1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 4.2.7.1
40
+ version: 4.2.8.rc1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: arel
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -299,14 +299,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
299
299
  version: 1.9.3
300
300
  required_rubygems_version: !ruby/object:Gem::Requirement
301
301
  requirements:
302
- - - ">="
302
+ - - ">"
303
303
  - !ruby/object:Gem::Version
304
- version: '0'
304
+ version: 1.3.1
305
305
  requirements: []
306
306
  rubyforge_project:
307
- rubygems_version: 2.6.6
307
+ rubygems_version: 2.6.10
308
308
  signing_key:
309
309
  specification_version: 4
310
310
  summary: Object-relational mapper framework (part of Rails).
311
311
  test_files: []
312
- has_rdoc: