activerecord 4.2.0.beta1 → 4.2.0.beta2

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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +137 -38
  3. data/lib/active_record/associations.rb +78 -13
  4. data/lib/active_record/associations/association_scope.rb +53 -40
  5. data/lib/active_record/associations/collection_association.rb +1 -1
  6. data/lib/active_record/associations/collection_proxy.rb +4 -4
  7. data/lib/active_record/associations/has_many_through_association.rb +6 -6
  8. data/lib/active_record/associations/join_dependency/join_association.rb +1 -1
  9. data/lib/active_record/associations/preloader.rb +32 -23
  10. data/lib/active_record/associations/singular_association.rb +1 -1
  11. data/lib/active_record/associations/through_association.rb +5 -1
  12. data/lib/active_record/attribute_methods.rb +7 -7
  13. data/lib/active_record/attribute_methods/dirty.rb +20 -9
  14. data/lib/active_record/attribute_methods/query.rb +1 -1
  15. data/lib/active_record/attribute_methods/read.rb +1 -3
  16. data/lib/active_record/attribute_methods/serialization.rb +3 -4
  17. data/lib/active_record/attribute_methods/time_zone_conversion.rb +2 -0
  18. data/lib/active_record/autosave_association.rb +3 -3
  19. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +1 -1
  20. data/lib/active_record/connection_adapters/abstract/database_statements.rb +5 -0
  21. data/lib/active_record/connection_adapters/abstract/schema_creation.rb +2 -0
  22. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +5 -8
  23. data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +8 -4
  24. data/lib/active_record/connection_adapters/abstract/transaction.rb +11 -5
  25. data/lib/active_record/connection_adapters/abstract_adapter.rb +7 -1
  26. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +23 -15
  27. data/lib/active_record/connection_adapters/mysql2_adapter.rb +1 -1
  28. data/lib/active_record/connection_adapters/mysql_adapter.rb +1 -1
  29. data/lib/active_record/connection_adapters/postgresql/oid/range.rb +4 -4
  30. data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +2 -0
  31. data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +3 -5
  32. data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +8 -6
  33. data/lib/active_record/connection_adapters/postgresql_adapter.rb +9 -6
  34. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +6 -5
  35. data/lib/active_record/core.rb +11 -3
  36. data/lib/active_record/counter_cache.rb +1 -1
  37. data/lib/active_record/fixtures.rb +15 -8
  38. data/lib/active_record/gem_version.rb +2 -2
  39. data/lib/active_record/migration.rb +8 -12
  40. data/lib/active_record/reflection.rb +20 -18
  41. data/lib/active_record/relation/calculations.rb +7 -7
  42. data/lib/active_record/relation/finder_methods.rb +10 -9
  43. data/lib/active_record/relation/predicate_builder.rb +2 -2
  44. data/lib/active_record/relation/predicate_builder/array_handler.rb +12 -4
  45. data/lib/active_record/relation/query_methods.rb +8 -12
  46. data/lib/active_record/schema_dumper.rb +20 -28
  47. data/lib/active_record/tasks/database_tasks.rb +9 -5
  48. data/lib/active_record/transactions.rb +9 -9
  49. data/lib/active_record/type.rb +1 -0
  50. data/lib/active_record/type/binary.rb +10 -0
  51. data/lib/active_record/type/decorator.rb +14 -0
  52. data/lib/active_record/type/serialized.rb +8 -3
  53. metadata +7 -6
@@ -131,10 +131,12 @@ module ActiveRecord
131
131
  verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
132
132
  version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
133
133
  scope = ENV['SCOPE']
134
- Migration.verbose = verbose
134
+ verbose_was, Migration.verbose = Migration.verbose, verbose
135
135
  Migrator.migrate(Migrator.migrations_paths, version) do |migration|
136
136
  scope.blank? || scope == migration.scope
137
137
  end
138
+ ensure
139
+ Migration.verbose = verbose_was
138
140
  end
139
141
 
140
142
  def charset_current(environment = env)
@@ -169,6 +171,7 @@ module ActiveRecord
169
171
  each_current_configuration(environment) { |configuration|
170
172
  purge configuration
171
173
  }
174
+ ActiveRecord::Base.establish_connection(environment.to_sym)
172
175
  end
173
176
 
174
177
  def structure_dump(*arguments)
@@ -184,10 +187,10 @@ module ActiveRecord
184
187
  end
185
188
 
186
189
  def load_schema(format = ActiveRecord::Base.schema_format, file = nil)
187
- ActiveSupport::Deprecation.warn(<<-MESSAGE.strip_heredoc)
188
- This method will act on a specific connection in the future.
189
- To act on the current connection, use `load_schema_current` instead.
190
- MESSAGE
190
+ ActiveSupport::Deprecation.warn \
191
+ "This method will act on a specific connection in the future. " \
192
+ "To act on the current connection, use `load_schema_current` instead."
193
+
191
194
  load_schema_current(format, file)
192
195
  end
193
196
 
@@ -215,6 +218,7 @@ module ActiveRecord
215
218
  each_current_configuration(environment) { |configuration|
216
219
  load_schema_for configuration, format, file
217
220
  }
221
+ ActiveRecord::Base.establish_connection(environment.to_sym)
218
222
  end
219
223
 
220
224
  def check_schema_file(filename)
@@ -3,15 +3,15 @@ module ActiveRecord
3
3
  module Transactions
4
4
  extend ActiveSupport::Concern
5
5
  ACTIONS = [:create, :destroy, :update]
6
- CALLBACK_WARN_MESSAGE = <<-EOF
7
- Currently, Active Record will rescue any errors raised within
8
- after_rollback/after_commit callbacks and print them to the logs. In the next
9
- version, these errors will no longer be rescued. Instead, they will simply
10
- bubble just like other Active Record callbacks.
11
-
12
- You can opt into the new behavior and remove this warning by setting
13
- config.active_record.raise_in_transactional_callbacks to true.
14
- EOF
6
+ CALLBACK_WARN_MESSAGE = "Currently, Active Record suppresses errors raised " \
7
+ "within `after_rollback`/`after_commit` callbacks and only print them to " \
8
+ "the logs. In the next version, these errors will no longer be suppressed. " \
9
+ "Instead, the errors will propagate normally just like in other Active " \
10
+ "Record callbacks.\n" \
11
+ "\n" \
12
+ "You can opt into the new behavior and remove this warning by setting:\n" \
13
+ "\n" \
14
+ " config.active_record.raise_in_transactional_callbacks = true"
15
15
 
16
16
  included do
17
17
  define_callbacks :commit, :rollback,
@@ -1,3 +1,4 @@
1
+ require 'active_record/type/decorator'
1
2
  require 'active_record/type/mutable'
2
3
  require 'active_record/type/numeric'
3
4
  require 'active_record/type/time_value'
@@ -22,6 +22,11 @@ module ActiveRecord
22
22
  Data.new(super)
23
23
  end
24
24
 
25
+ def changed_in_place?(raw_old_value, value)
26
+ old_value = type_cast_from_database(raw_old_value)
27
+ old_value != value
28
+ end
29
+
25
30
  class Data # :nodoc:
26
31
  def initialize(value)
27
32
  @value = value.to_s
@@ -30,10 +35,15 @@ module ActiveRecord
30
35
  def to_s
31
36
  @value
32
37
  end
38
+ alias_method :to_str, :to_s
33
39
 
34
40
  def hex
35
41
  @value.unpack('H*')[0]
36
42
  end
43
+
44
+ def ==(other)
45
+ other == to_s || super
46
+ end
37
47
  end
38
48
  end
39
49
  end
@@ -0,0 +1,14 @@
1
+ module ActiveRecord
2
+ module Type
3
+ module Decorator # :nodoc:
4
+ def init_with(coder)
5
+ @subtype = coder['subtype']
6
+ __setobj__(@subtype)
7
+ end
8
+
9
+ def encode_with(coder)
10
+ coder['subtype'] = __getobj__
11
+ end
12
+ end
13
+ end
14
+ end
@@ -2,6 +2,7 @@ module ActiveRecord
2
2
  module Type
3
3
  class Serialized < SimpleDelegator # :nodoc:
4
4
  include Mutable
5
+ include Decorator
5
6
 
6
7
  attr_reader :subtype, :coder
7
8
 
@@ -26,19 +27,23 @@ module ActiveRecord
26
27
  end
27
28
  end
28
29
 
30
+ def changed_in_place?(raw_old_value, value)
31
+ return false if value.nil?
32
+ subtype.changed_in_place?(raw_old_value, coder.dump(value))
33
+ end
34
+
29
35
  def accessor
30
36
  ActiveRecord::Store::IndifferentHashAccessor
31
37
  end
32
38
 
33
39
  def init_with(coder)
34
- @subtype = coder['subtype']
35
40
  @coder = coder['coder']
36
- __setobj__(@subtype)
41
+ super
37
42
  end
38
43
 
39
44
  def encode_with(coder)
40
- coder['subtype'] = @subtype
41
45
  coder['coder'] = @coder
46
+ super
42
47
  end
43
48
 
44
49
  private
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.0.beta1
4
+ version: 4.2.0.beta2
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: 2014-08-20 00:00:00.000000000 Z
11
+ date: 2014-09-26 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.0.beta1
19
+ version: 4.2.0.beta2
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.0.beta1
26
+ version: 4.2.0.beta2
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.0.beta1
33
+ version: 4.2.0.beta2
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.0.beta1
40
+ version: 4.2.0.beta2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: arel
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -258,6 +258,7 @@ files:
258
258
  - lib/active_record/type/date_time.rb
259
259
  - lib/active_record/type/decimal.rb
260
260
  - lib/active_record/type/decimal_without_scale.rb
261
+ - lib/active_record/type/decorator.rb
261
262
  - lib/active_record/type/float.rb
262
263
  - lib/active_record/type/hash_lookup_type_map.rb
263
264
  - lib/active_record/type/integer.rb