activerecord 4.0.9 → 4.0.10.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: 1c03598a80e4948e20c4365cd9c27736d19ff1c9
4
- data.tar.gz: 434049ee7aba353e571a54c3b8658a693ea323c0
3
+ metadata.gz: 9e2615e59df2a45d733db0443fc18cdcbbe8c23a
4
+ data.tar.gz: 4f80740add455d8f6216565e6173b926d3966098
5
5
  SHA512:
6
- metadata.gz: a2009b19504ecb4c0e58fd4c4d527e934bfcf916dcc751250a19b6f216534fb4a2bcbcad81cb13f93e12e4bc3548faffb5325a5df0fab7c7263e5c147d13e5e6
7
- data.tar.gz: c07330c8216c0d36a0c5bf0a081550469a36647ac26d4cc43a570ddb93c62bf3044fd4fd8631cf11430193f50fb9f04f7c44b1b09b9f7ab9afbd647a24327dca
6
+ metadata.gz: 75ebff890bf4e8fbd498066ca8ee231b07f7f6194f48eeb01a1ac6aec6f045bcdbd5bf307e57160a2542a1416167becf0ba949ae6e313d542f8e162efe03539b
7
+ data.tar.gz: a523ea0a98c5bd43b62b90c02053fcc0056213ac411769675cf43e4be641e2839f96c6f31477d8e0bdc175df71fa4336aced6a9b528ae04d91c6620fe1f4f40d
@@ -1,3 +1,82 @@
1
+ ## Rails 4.0.10 (August 19, 2014) ##
2
+
3
+ * Fix regression on after_commit that didnt fire when having nested transactions.
4
+
5
+ Fixes #16425
6
+
7
+ *arthurnn*
8
+
9
+ * Define `id_was` to get the previous value of the primary key.
10
+
11
+ Currently when we call id_was and we have a custom primary key name
12
+ Active Record will return the current value of the primary key. This
13
+ make impossible to correctly do an update operation if you change the
14
+ id.
15
+
16
+ Fixes #16413.
17
+
18
+ *Rafael Mendonça França*
19
+
20
+ * Fixed error in `reset_counters` when associations have `select` scope.
21
+ (Call to `count` generates invalid SQL.)
22
+
23
+ *Cade Truitt*
24
+
25
+ * After a successful `reload`, `new_record?` is always false.
26
+
27
+ Fixes #12101.
28
+
29
+ *Matthew Draper*
30
+
31
+ * `has_many :through` associations will no longer save the through record
32
+ twice when added in an `after_create` callback defined before the
33
+ associations.
34
+
35
+ *Sean Griffin*
36
+
37
+ * Correctly extract IPv6 addresses from `DATABASE_URI`: the square brackets
38
+ are part of the URI structure, not the actual host.
39
+
40
+ Fixes #15705.
41
+
42
+ *Andy Bakun*, *Aaron Stone*
43
+
44
+ * Don't error when quoting user defined types in PostgreSQL.
45
+
46
+ Fixes #15697.
47
+
48
+ *Sean Griffin*
49
+
50
+ * `ActiveRecord::FinderMethods.find` with block can handle proc parameter as
51
+ `Enumerable#find` does.
52
+
53
+ Fixes #15382.
54
+
55
+ *James Yang*
56
+
57
+ * `ActiveRecord::SchemaMigration` has no primary key regardless of the
58
+ `primary_key_prefix_type` configuration.
59
+
60
+ Fixes #15051.
61
+
62
+ *JoseLuis Torres*, *Yves Senn*
63
+
64
+ * `rake db:migrate:status` works with legacy migration numbers like `00018_xyz.rb`.
65
+
66
+ Fixes #15538.
67
+
68
+ *Yves Senn*
69
+
70
+ * Fixed `columns_for_distinct` of postgresql adapter to work correctly
71
+ with orders without sort direction modifiers.
72
+
73
+ *Nikolay Kondratyev*
74
+
75
+ * `rake railties:install:migrations` respects the order of railties.
76
+
77
+ *Arun Agrawal*
78
+
79
+
1
80
  ## Rails 4.0.9 (August 18, 2014) ##
2
81
 
3
82
  * Check attributes passed to `create_with` and `where`.
@@ -1396,7 +1396,7 @@ module ActiveRecord
1396
1396
  # belongs_to :firm, foreign_key: "client_of"
1397
1397
  # belongs_to :person, primary_key: "name", foreign_key: "person_name"
1398
1398
  # belongs_to :author, class_name: "Person", foreign_key: "author_id"
1399
- # belongs_to :valid_coupon, ->(o) { where "discounts > #{o.payments_count}" },
1399
+ # belongs_to :valid_coupon, ->(o) { where "discounts > ?", o.payments_count },
1400
1400
  # class_name: "Coupon", foreign_key: "coupon_id"
1401
1401
  # belongs_to :attachable, polymorphic: true
1402
1402
  # belongs_to :project, readonly: true
@@ -60,8 +60,10 @@ module ActiveRecord
60
60
  join.left.downcase.scan(
61
61
  /join(?:\s+\w+)?\s+(\S+\s+)?#{quoted_name}\son/
62
62
  ).size
63
- else
63
+ elsif join.respond_to? :left
64
64
  join.left.table_name == name ? 1 : 0
65
+ else
66
+ 0
65
67
  end
66
68
  end
67
69
 
@@ -37,6 +37,12 @@ module ActiveRecord
37
37
  read_attribute_before_type_cast(self.class.primary_key)
38
38
  end
39
39
 
40
+ # Returns the primary key previous value.
41
+ def id_was
42
+ sync_with_transaction_state
43
+ attribute_was(self.class.primary_key)
44
+ end
45
+
40
46
  protected
41
47
 
42
48
  def attribute_method?(attr_name)
@@ -52,7 +58,7 @@ module ActiveRecord
52
58
  end
53
59
  end
54
60
 
55
- ID_ATTRIBUTE_METHODS = %w(id id= id? id_before_type_cast).to_set
61
+ ID_ATTRIBUTE_METHODS = %w(id id= id? id_before_type_cast id_was).to_set
56
62
 
57
63
  def dangerous_attribute_method?(method_name)
58
64
  super && !ID_ATTRIBUTE_METHODS.include?(method_name)
@@ -359,6 +359,7 @@ module ActiveRecord
359
359
 
360
360
  raise ActiveRecord::Rollback unless saved
361
361
  end
362
+ @new_record_before_save = false unless reflection.macro == :has_and_belongs_to_many
362
363
  end
363
364
 
364
365
  # reconstruct the scope now that we know the owner's id
@@ -201,6 +201,7 @@ module ActiveRecord
201
201
  @state.set_state(:committed)
202
202
  @state.parent = parent.state
203
203
  connection.release_savepoint
204
+ records.each { |r| parent.add_record(r) }
204
205
  end
205
206
  end
206
207
  end
@@ -757,8 +757,8 @@ module ActiveRecord
757
757
  # Make MySQL reject illegal values rather than truncating or blanking them, see
758
758
  # http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html#sqlmode_strict_all_tables
759
759
  # If the user has provided another value for sql_mode, don't replace it.
760
- if strict_mode? && !variables.has_key?('sql_mode')
761
- variables['sql_mode'] = 'STRICT_ALL_TABLES'
760
+ unless variables.has_key?('sql_mode')
761
+ variables['sql_mode'] = strict_mode? ? 'STRICT_ALL_TABLES' : ''
762
762
  end
763
763
 
764
764
  # NAMES does not have an equals sign, see
@@ -74,7 +74,7 @@ module ActiveRecord
74
74
  :password => config.password,
75
75
  :port => config.port,
76
76
  :database => config.path.sub(%r{^/},""),
77
- :host => config.host }
77
+ :host => config.hostname }
78
78
 
79
79
  spec.reject!{ |_,value| value.blank? }
80
80
 
@@ -16,7 +16,7 @@ module ActiveRecord
16
16
 
17
17
  # Quotes PostgreSQL-specific data types for SQL input.
18
18
  def quote(value, column = nil) #:nodoc:
19
- return super unless column
19
+ return super unless column && column.type
20
20
 
21
21
  sql_type = type_to_sql(column.type, column.limit, column.precision, column.scale)
22
22
 
@@ -493,7 +493,7 @@ module ActiveRecord
493
493
  # Convert Arel node to string
494
494
  s = s.to_sql unless s.is_a?(String)
495
495
  # Remove any ASC/DESC modifiers
496
- s.gsub(/\s+(ASC|DESC)\s*(NULLS\s+(FIRST|LAST)\s*)?/i, '')
496
+ s.gsub(/\s+(?:ASC|DESC)?\s*(?:NULLS\s+(?:FIRST|LAST)\s*)?/i, '')
497
497
  }.reject(&:blank?).map.with_index { |column, i| "#{column} AS alias_#{i}" }
498
498
 
499
499
  [super, *order_columns].join(', ')
@@ -34,7 +34,7 @@ module ActiveRecord
34
34
  counter_name = reflection.counter_cache_column
35
35
 
36
36
  stmt = unscoped.where(arel_table[primary_key].eq(object.id)).arel.compile_update({
37
- arel_table[counter_name] => object.send(association).count
37
+ arel_table[counter_name] => object.send(association).count(:all)
38
38
  })
39
39
  connection.update stmt
40
40
  end
@@ -679,7 +679,7 @@ module ActiveRecord
679
679
  if ActiveRecord::Base.timestamped_migrations
680
680
  [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % number].max
681
681
  else
682
- "%.3d" % number
682
+ SchemaMigration.normalize_migration_number(number)
683
683
  end
684
684
  end
685
685
 
@@ -397,6 +397,7 @@ module ActiveRecord
397
397
  @column_types = self.class.column_types
398
398
  @column_types_override = fresh_object.instance_variable_get('@column_types_override')
399
399
  @attributes_cache = {}
400
+ @new_record = false
400
401
  self
401
402
  end
402
403
 
@@ -95,14 +95,15 @@ db_namespace = namespace :db do
95
95
  next # means "return" for rake task
96
96
  end
97
97
  db_list = ActiveRecord::Base.connection.select_values("SELECT version FROM #{ActiveRecord::Migrator.schema_migrations_table_name}")
98
- db_list.map! { |version| "%.3d" % version }
98
+ db_list.map! { |version| ActiveRecord::SchemaMigration.normalize_migration_number(version) }
99
99
  file_list = []
100
100
  ActiveRecord::Migrator.migrations_paths.each do |path|
101
101
  Dir.foreach(path) do |file|
102
102
  # match "20091231235959_some_name.rb" and "001_some_name.rb" pattern
103
103
  if match_data = /^(\d{3,})_(.+)\.rb$/.match(file)
104
- status = db_list.delete(match_data[1]) ? 'up' : 'down'
105
- file_list << [status, match_data[1], match_data[2].humanize]
104
+ version = ActiveRecord::SchemaMigration.normalize_migration_number(match_data[1])
105
+ status = db_list.delete(version) ? 'up' : 'down'
106
+ file_list << [status, version, match_data[2].humanize]
106
107
  end
107
108
  end
108
109
  end
@@ -380,7 +381,7 @@ namespace :railties do
380
381
  task :migrations => :'db:load_config' do
381
382
  to_load = ENV['FROM'].blank? ? :all : ENV['FROM'].split(",").map {|n| n.strip }
382
383
  railties = {}
383
- Rails.application.railties.each do |railtie|
384
+ Rails.application.migration_railties.each do |railtie|
384
385
  next unless to_load == :all || to_load.include?(railtie.railtie_name)
385
386
 
386
387
  if railtie.respond_to?(:paths) && (path = railtie.paths['db/migrate'].first)
@@ -31,7 +31,7 @@ module ActiveRecord
31
31
  # end
32
32
  def find(*args)
33
33
  if block_given?
34
- to_a.find { |*block_args| yield(*block_args) }
34
+ to_a.find(*args) { |*block_args| yield(*block_args) }
35
35
  else
36
36
  find_with_ids(*args)
37
37
  end
@@ -212,7 +212,7 @@ module ActiveRecord
212
212
 
213
213
  def construct_join_dependency_for_association_find
214
214
  including = (eager_load_values + includes_values).uniq
215
- ActiveRecord::Associations::JoinDependency.new(@klass, including, [])
215
+ ActiveRecord::Associations::JoinDependency.new(@klass, including, joins_values)
216
216
  end
217
217
 
218
218
  def construct_relation_for_association_calculations
@@ -4,6 +4,9 @@ require 'active_record/base'
4
4
 
5
5
  module ActiveRecord
6
6
  class SchemaMigration < ActiveRecord::Base
7
+ def self.primary_key
8
+ nil
9
+ end
7
10
 
8
11
  def self.table_name
9
12
  "#{Base.table_name_prefix}schema_migrations#{Base.table_name_suffix}"
@@ -32,6 +35,10 @@ module ActiveRecord
32
35
  end
33
36
  end
34
37
 
38
+ def self.normalize_migration_number(number)
39
+ "%.3d" % number.to_i
40
+ end
41
+
35
42
  def version
36
43
  super.to_i
37
44
  end
@@ -1,7 +1,7 @@
1
1
  module ActiveRecord
2
2
  # Returns the version of the currently loaded ActiveRecord as a Gem::Version
3
3
  def self.version
4
- Gem::Version.new "4.0.9"
4
+ Gem::Version.new "4.0.10.rc1"
5
5
  end
6
6
 
7
7
  module VERSION #:nodoc:
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.0.9
4
+ version: 4.0.10.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: 2014-08-18 00:00:00.000000000 Z
11
+ date: 2014-08-19 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.0.9
19
+ version: 4.0.10.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.0.9
26
+ version: 4.0.10.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.0.9
33
+ version: 4.0.10.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.0.9
40
+ version: 4.0.10.rc1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: arel
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -255,9 +255,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
255
255
  version: 1.9.3
256
256
  required_rubygems_version: !ruby/object:Gem::Requirement
257
257
  requirements:
258
- - - ">="
258
+ - - ">"
259
259
  - !ruby/object:Gem::Version
260
- version: '0'
260
+ version: 1.3.1
261
261
  requirements: []
262
262
  rubyforge_project:
263
263
  rubygems_version: 2.3.0