activerecord 4.1.8 → 4.1.9.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 +4 -4
- data/CHANGELOG.md +65 -0
- data/lib/active_record/associations/association_scope.rb +1 -5
- data/lib/active_record/associations/collection_association.rb +14 -3
- data/lib/active_record/associations/preloader.rb +1 -0
- data/lib/active_record/associations/preloader/association.rb +1 -0
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +13 -1
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +2 -2
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +3 -3
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +2 -2
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +3 -0
- data/lib/active_record/core.rb +0 -1
- data/lib/active_record/fixtures.rb +1 -1
- data/lib/active_record/gem_version.rb +2 -2
- data/lib/active_record/migration.rb +8 -1
- data/lib/active_record/railtie.rb +0 -2
- data/lib/active_record/railties/databases.rake +6 -6
- data/lib/active_record/reflection.rb +5 -2
- data/lib/active_record/tasks/database_tasks.rb +0 -2
- data/lib/active_record/transactions.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5287fa16445f7b98a3fcea72da500425ec78bd5
|
4
|
+
data.tar.gz: e0506df4805c389dfb5bba80a98213757853decd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee1d915128d2cf0959ad1e3e40f4260d46c8fcf86442b3431d1a0f2725af36ec03696f8b1410d50342eec5c8c12d5bbaea2a8aec010b87c6a11917607edd5c4a
|
7
|
+
data.tar.gz: 2e39f5e3a3679cec9ab406e15f3d53697a6f7f842d04349816d1dfc14da1cd80efc64cd64fd76f78d72a562cc28ae65a4d50ed2e93f42bf420ea573aa4c38d91
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,58 @@
|
|
1
|
+
* `db:schema:load` and `db:structure:load` no longer purge the database
|
2
|
+
before loading the schema. This is left for the user to do.
|
3
|
+
`db:test:prepare` will still purge the database.
|
4
|
+
|
5
|
+
Closes #17945.
|
6
|
+
|
7
|
+
*Yves Senn*
|
8
|
+
|
9
|
+
* Bring back `db:test:prepare` to synchronize the test database schema.
|
10
|
+
|
11
|
+
Manual synchronization using `bin/rake db:test:prepare` is required
|
12
|
+
when a migration is rolled-back, edited and reapplied.
|
13
|
+
|
14
|
+
`ActiveRecord::Base.maintain_test_schema` now uses `db:test:prepare`
|
15
|
+
to synchronize the schema. Plugins can use this task as a hook to
|
16
|
+
provide custom behavior after the schema has been loaded.
|
17
|
+
|
18
|
+
NOTE: `test:prepare` runs before the schema was synchronized.
|
19
|
+
|
20
|
+
Fixes #17171, #15787.
|
21
|
+
|
22
|
+
*Yves Senn*
|
23
|
+
|
24
|
+
* Renaming a table in pg also renames the primary key index.
|
25
|
+
|
26
|
+
Fixes #12856
|
27
|
+
|
28
|
+
*Sean Griffin*
|
29
|
+
|
30
|
+
* Make it possible to access fixtures excluded by a `default_scope`.
|
31
|
+
|
32
|
+
*Yves Senn*
|
33
|
+
|
34
|
+
* `timestamps` and `add_timestamps` passes additional options along.
|
35
|
+
(like `null: false`)
|
36
|
+
|
37
|
+
Closes #17624.
|
38
|
+
|
39
|
+
*Yves Senn*
|
40
|
+
|
41
|
+
|
42
|
+
## Rails 4.1.8 (November 16, 2014) ##
|
43
|
+
|
44
|
+
* Cache `CollectionAssociation#reader` proxies separately before and after
|
45
|
+
the owner has been saved so that the proxy is not cached without the
|
46
|
+
owner's id.
|
47
|
+
|
48
|
+
*Ben Woosley*
|
49
|
+
|
50
|
+
* Fix preloading of associations which unscope a default scope.
|
51
|
+
|
52
|
+
Fixes #11036.
|
53
|
+
|
54
|
+
*Byron Bischoff*
|
55
|
+
|
1
56
|
* Do not use `RENAME INDEX` syntax for MariaDB 10.0.
|
2
57
|
|
3
58
|
Fixes #15931.
|
@@ -36,6 +91,16 @@
|
|
36
91
|
*Agis Anastasopoulos*
|
37
92
|
|
38
93
|
|
94
|
+
## Rails 4.1.7.1 (November 19, 2014) ##
|
95
|
+
|
96
|
+
* No changes.
|
97
|
+
|
98
|
+
|
99
|
+
## Rails 4.1.7 (October 29, 2014) ##
|
100
|
+
|
101
|
+
* No changes.
|
102
|
+
|
103
|
+
|
39
104
|
## Rails 4.1.6 (September 11, 2014) ##
|
40
105
|
|
41
106
|
* Fixed a regression where whitespaces were stripped from DISTINCT queries in
|
@@ -143,11 +143,7 @@ module ActiveRecord
|
|
143
143
|
end
|
144
144
|
|
145
145
|
def eval_scope(klass, scope, owner)
|
146
|
-
|
147
|
-
scope
|
148
|
-
else
|
149
|
-
klass.unscoped.instance_exec(owner, &scope)
|
150
|
-
end
|
146
|
+
klass.unscoped.instance_exec(owner, &scope)
|
151
147
|
end
|
152
148
|
end
|
153
149
|
end
|
@@ -33,7 +33,13 @@ module ActiveRecord
|
|
33
33
|
reload
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
if owner.new_record?
|
37
|
+
# Cache the proxy separately before the owner has an id
|
38
|
+
# or else a post-save proxy will still lack the id
|
39
|
+
@new_record_proxy ||= CollectionProxy.create(klass, self)
|
40
|
+
else
|
41
|
+
@proxy ||= CollectionProxy.create(klass, self)
|
42
|
+
end
|
37
43
|
end
|
38
44
|
|
39
45
|
# Implements the writer method, e.g. foo.items= for Foo.has_many :items
|
@@ -560,8 +566,13 @@ module ActiveRecord
|
|
560
566
|
if reflection.is_a?(ActiveRecord::Reflection::ThroughReflection)
|
561
567
|
assoc = owner.association(reflection.through_reflection.name)
|
562
568
|
assoc.reader.any? { |source|
|
563
|
-
|
564
|
-
|
569
|
+
target_association = source.send(reflection.source_reflection.name)
|
570
|
+
|
571
|
+
if target_association.respond_to?(:include?)
|
572
|
+
target_association.include?(record)
|
573
|
+
else
|
574
|
+
target_association == record
|
575
|
+
end
|
565
576
|
} || target.include?(record)
|
566
577
|
else
|
567
578
|
target.include?(record)
|
@@ -34,7 +34,7 @@ module ActiveRecord
|
|
34
34
|
if create_time_zone_conversion_attribute?(attr_name, columns_hash[attr_name])
|
35
35
|
method_body, line = <<-EOV, __LINE__ + 1
|
36
36
|
def #{attr_name}=(time)
|
37
|
-
time_with_zone =
|
37
|
+
time_with_zone = convert_value_to_time_zone("#{attr_name}", time)
|
38
38
|
previous_time = attribute_changed?("#{attr_name}") ? changed_attributes["#{attr_name}"] : read_attribute(:#{attr_name})
|
39
39
|
write_attribute(:#{attr_name}, time)
|
40
40
|
#{attr_name}_will_change! if previous_time != time_with_zone
|
@@ -54,6 +54,18 @@ module ActiveRecord
|
|
54
54
|
(:datetime == column.type || :timestamp == column.type)
|
55
55
|
end
|
56
56
|
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def convert_value_to_time_zone(attr_name, value)
|
61
|
+
if value.is_a?(Array)
|
62
|
+
value.map { |v| convert_value_to_time_zone(attr_name, v) }
|
63
|
+
elsif value.respond_to?(:in_time_zone)
|
64
|
+
value.in_time_zone || self.class.columns_hash[attr_name].type_cast(value)
|
65
|
+
else
|
66
|
+
nil
|
67
|
+
end
|
68
|
+
end
|
57
69
|
end
|
58
70
|
end
|
59
71
|
end
|
@@ -394,8 +394,8 @@ module ActiveRecord
|
|
394
394
|
# Adds timestamps (+created_at+ and +updated_at+) columns to the table. See SchemaStatements#add_timestamps
|
395
395
|
#
|
396
396
|
# t.timestamps
|
397
|
-
def timestamps
|
398
|
-
@base.add_timestamps(@table_name)
|
397
|
+
def timestamps(options = {})
|
398
|
+
@base.add_timestamps(@table_name, options)
|
399
399
|
end
|
400
400
|
|
401
401
|
# Changes the column's definition according to the new options.
|
@@ -722,9 +722,9 @@ module ActiveRecord
|
|
722
722
|
#
|
723
723
|
# add_timestamps(:suppliers)
|
724
724
|
#
|
725
|
-
def add_timestamps(table_name)
|
726
|
-
add_column table_name, :created_at, :datetime
|
727
|
-
add_column table_name, :updated_at, :datetime
|
725
|
+
def add_timestamps(table_name, options = {})
|
726
|
+
add_column table_name, :created_at, :datetime, options
|
727
|
+
add_column table_name, :updated_at, :datetime, options
|
728
728
|
end
|
729
729
|
|
730
730
|
# Removes the timestamp columns (+created_at+ and +updated_at+) from the table definition.
|
@@ -717,8 +717,8 @@ module ActiveRecord
|
|
717
717
|
"DROP INDEX #{index_name}"
|
718
718
|
end
|
719
719
|
|
720
|
-
def add_timestamps_sql(table_name)
|
721
|
-
[add_column_sql(table_name, :created_at, :datetime), add_column_sql(table_name, :updated_at, :datetime)]
|
720
|
+
def add_timestamps_sql(table_name, options = {})
|
721
|
+
[add_column_sql(table_name, :created_at, :datetime, options), add_column_sql(table_name, :updated_at, :datetime, options)]
|
722
722
|
end
|
723
723
|
|
724
724
|
def remove_timestamps_sql(table_name)
|
@@ -382,7 +382,10 @@ module ActiveRecord
|
|
382
382
|
pk, seq = pk_and_sequence_for(new_name)
|
383
383
|
if seq == "#{table_name}_#{pk}_seq"
|
384
384
|
new_seq = "#{new_name}_#{pk}_seq"
|
385
|
+
idx = "#{table_name}_pkey"
|
386
|
+
new_idx = "#{new_name}_pkey"
|
385
387
|
execute "ALTER TABLE #{quote_table_name(seq)} RENAME TO #{quote_table_name(new_seq)}"
|
388
|
+
execute "ALTER INDEX #{quote_table_name(idx)} RENAME TO #{quote_table_name(new_idx)}"
|
386
389
|
end
|
387
390
|
|
388
391
|
rename_table_indexes(table_name, new_name)
|
data/lib/active_record/core.rb
CHANGED
@@ -85,7 +85,6 @@ module ActiveRecord
|
|
85
85
|
mattr_accessor :dump_schema_after_migration, instance_writer: false
|
86
86
|
self.dump_schema_after_migration = true
|
87
87
|
|
88
|
-
# :nodoc:
|
89
88
|
mattr_accessor :maintain_test_schema, instance_accessor: false
|
90
89
|
|
91
90
|
def self.disable_implicit_join_references=(value)
|
@@ -790,7 +790,7 @@ module ActiveRecord
|
|
790
790
|
|
791
791
|
def find
|
792
792
|
if model_class
|
793
|
-
model_class.find(fixture[model_class.primary_key])
|
793
|
+
model_class.unscoped.find(fixture[model_class.primary_key])
|
794
794
|
else
|
795
795
|
raise FixtureClassNotFound, "No class attached to find."
|
796
796
|
end
|
@@ -391,7 +391,14 @@ module ActiveRecord
|
|
391
391
|
|
392
392
|
def load_schema_if_pending!
|
393
393
|
if ActiveRecord::Migrator.needs_migration?
|
394
|
-
|
394
|
+
# Roundrip to Rake to allow plugins to hook into database initialization.
|
395
|
+
FileUtils.cd Rails.root do
|
396
|
+
current_config = Base.connection_config
|
397
|
+
Base.clear_all_connections!
|
398
|
+
system("bin/rake db:test:prepare")
|
399
|
+
# Establish a new connection, the old database may be gone (db:test:prepare uses purge)
|
400
|
+
Base.establish_connection(current_config)
|
401
|
+
end
|
395
402
|
check_pending!
|
396
403
|
end
|
397
404
|
end
|
@@ -36,8 +36,6 @@ module ActiveRecord
|
|
36
36
|
config.eager_load_namespaces << ActiveRecord
|
37
37
|
|
38
38
|
rake_tasks do
|
39
|
-
require "active_record/base"
|
40
|
-
|
41
39
|
namespace :db do
|
42
40
|
task :load_config do
|
43
41
|
ActiveRecord::Tasks::DatabaseTasks.database_configuration = Rails.application.config.database_configuration
|
@@ -234,7 +234,7 @@ db_namespace = namespace :db do
|
|
234
234
|
end
|
235
235
|
|
236
236
|
desc 'Load a schema.rb file into the database'
|
237
|
-
task :load => [:
|
237
|
+
task :load => [:load_config] do
|
238
238
|
ActiveRecord::Tasks::DatabaseTasks.load_schema_current(:ruby, ENV['SCHEMA'])
|
239
239
|
end
|
240
240
|
|
@@ -299,7 +299,7 @@ db_namespace = namespace :db do
|
|
299
299
|
end
|
300
300
|
|
301
301
|
# desc "Recreate the test database from the current schema"
|
302
|
-
task :load => %w(db:test:
|
302
|
+
task :load => %w(db:test:purge) do
|
303
303
|
case ActiveRecord::Base.schema_format
|
304
304
|
when :ruby
|
305
305
|
db_namespace["test:load_schema"].invoke
|
@@ -309,7 +309,7 @@ db_namespace = namespace :db do
|
|
309
309
|
end
|
310
310
|
|
311
311
|
# desc "Recreate the test database from an existent schema.rb file"
|
312
|
-
task :load_schema => %w(db:test:
|
312
|
+
task :load_schema => %w(db:test:purge) do
|
313
313
|
begin
|
314
314
|
should_reconnect = ActiveRecord::Base.connection_pool.active_connection?
|
315
315
|
ActiveRecord::Schema.verbose = false
|
@@ -322,7 +322,7 @@ db_namespace = namespace :db do
|
|
322
322
|
end
|
323
323
|
|
324
324
|
# desc "Recreate the test database from an existent structure.sql file"
|
325
|
-
task :load_structure => %w(db:test:
|
325
|
+
task :load_structure => %w(db:test:purge) do
|
326
326
|
ActiveRecord::Tasks::DatabaseTasks.load_schema_for ActiveRecord::Base.configurations['test'], :sql, ENV['SCHEMA']
|
327
327
|
end
|
328
328
|
|
@@ -343,12 +343,12 @@ db_namespace = namespace :db do
|
|
343
343
|
task :clone_structure => %w(db:test:deprecated db:structure:dump db:test:load_structure)
|
344
344
|
|
345
345
|
# desc "Empty the test database"
|
346
|
-
task :purge => %w(
|
346
|
+
task :purge => %w(environment load_config) do
|
347
347
|
ActiveRecord::Tasks::DatabaseTasks.purge ActiveRecord::Base.configurations['test']
|
348
348
|
end
|
349
349
|
|
350
350
|
# desc 'Check for pending migrations and load the test schema'
|
351
|
-
task :prepare => %w(
|
351
|
+
task :prepare => %w(environment load_config) do
|
352
352
|
unless ActiveRecord::Base.configurations.blank?
|
353
353
|
db_namespace['test:load'].invoke
|
354
354
|
end
|
@@ -609,8 +609,11 @@ module ActiveRecord
|
|
609
609
|
through_scope_chain = through_reflection.scope_chain.map(&:dup)
|
610
610
|
|
611
611
|
if options[:source_type]
|
612
|
-
|
613
|
-
|
612
|
+
type = foreign_type
|
613
|
+
source_type = options[:source_type]
|
614
|
+
through_scope_chain.first << lambda { |object|
|
615
|
+
where(type => source_type)
|
616
|
+
}
|
614
617
|
end
|
615
618
|
|
616
619
|
# Recursively fill out the rest of the array from the through reflection
|
@@ -167,13 +167,11 @@ module ActiveRecord
|
|
167
167
|
when :ruby
|
168
168
|
file ||= File.join(db_dir, "schema.rb")
|
169
169
|
check_schema_file(file)
|
170
|
-
purge(configuration)
|
171
170
|
ActiveRecord::Base.establish_connection(configuration)
|
172
171
|
load(file)
|
173
172
|
when :sql
|
174
173
|
file ||= File.join(db_dir, "structure.sql")
|
175
174
|
check_schema_file(file)
|
176
|
-
purge(configuration)
|
177
175
|
structure_load(configuration, file)
|
178
176
|
else
|
179
177
|
raise ArgumentError, "unknown format #{format.inspect}"
|
@@ -249,7 +249,7 @@ module ActiveRecord
|
|
249
249
|
|
250
250
|
def assert_valid_transaction_action(actions)
|
251
251
|
if (actions - ACTIONS).any?
|
252
|
-
raise ArgumentError, ":on conditions for after_commit and after_rollback callbacks have to be one of #{ACTIONS
|
252
|
+
raise ArgumentError, ":on conditions for after_commit and after_rollback callbacks have to be one of #{ACTIONS}"
|
253
253
|
end
|
254
254
|
end
|
255
255
|
end
|
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.1.
|
4
|
+
version: 4.1.9.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:
|
11
|
+
date: 2015-01-02 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.1.
|
19
|
+
version: 4.1.9.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.1.
|
26
|
+
version: 4.1.9.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.1.
|
33
|
+
version: 4.1.9.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.1.
|
40
|
+
version: 4.1.9.rc1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: arel
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -243,12 +243,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
243
243
|
version: 1.9.3
|
244
244
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
245
245
|
requirements:
|
246
|
-
- - "
|
246
|
+
- - ">"
|
247
247
|
- !ruby/object:Gem::Version
|
248
|
-
version:
|
248
|
+
version: 1.3.1
|
249
249
|
requirements: []
|
250
250
|
rubyforge_project:
|
251
|
-
rubygems_version: 2.4.
|
251
|
+
rubygems_version: 2.4.5
|
252
252
|
signing_key:
|
253
253
|
specification_version: 4
|
254
254
|
summary: Object-relational mapper framework (part of Rails).
|