activerecord 4.2.2 → 4.2.3.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 +116 -1
- data/lib/active_record.rb +1 -0
- data/lib/active_record/association_relation.rb +13 -0
- data/lib/active_record/associations.rb +1 -1
- data/lib/active_record/associations/belongs_to_association.rb +5 -1
- data/lib/active_record/associations/builder/association.rb +1 -1
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +1 -1
- data/lib/active_record/associations/collection_proxy.rb +8 -7
- data/lib/active_record/associations/has_many_through_association.rb +1 -1
- data/lib/active_record/associations/join_dependency.rb +6 -1
- data/lib/active_record/associations/through_association.rb +1 -1
- data/lib/active_record/attribute_assignment.rb +1 -1
- data/lib/active_record/attribute_methods/dirty.rb +6 -1
- data/lib/active_record/base.rb +4 -5
- data/lib/active_record/callbacks.rb +6 -6
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +6 -2
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +4 -0
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +14 -22
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +27 -13
- data/lib/active_record/connection_adapters/abstract/transaction.rb +1 -5
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +6 -0
- data/lib/active_record/connection_adapters/mysql_adapter.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +17 -5
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +2 -4
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +7 -3
- data/lib/active_record/core.rb +17 -12
- data/lib/active_record/errors.rb +2 -2
- data/lib/active_record/explain_subscriber.rb +1 -1
- data/lib/active_record/fixtures.rb +8 -6
- data/lib/active_record/gem_version.rb +2 -2
- data/lib/active_record/migration.rb +1 -2
- data/lib/active_record/persistence.rb +5 -3
- data/lib/active_record/railties/databases.rake +1 -1
- data/lib/active_record/reflection.rb +2 -2
- data/lib/active_record/relation/delegation.rb +1 -1
- data/lib/active_record/relation/finder_methods.rb +3 -15
- data/lib/active_record/relation/predicate_builder.rb +11 -2
- data/lib/active_record/relation/query_methods.rb +13 -16
- data/lib/active_record/tasks/database_tasks.rb +1 -1
- data/lib/active_record/transactions.rb +14 -6
- data/lib/active_record/type/boolean.rb +1 -0
- data/lib/active_record/type/hash_lookup_type_map.rb +8 -2
- data/lib/active_record/type/serialized.rb +7 -1
- data/lib/active_record/validations/uniqueness.rb +9 -5
- metadata +8 -8
@@ -530,6 +530,8 @@ module ActiveRecord
|
|
530
530
|
#
|
531
531
|
# CREATE UNIQUE INDEX index_accounts_on_branch_id_and_party_id ON accounts(branch_id, party_id) WHERE active
|
532
532
|
#
|
533
|
+
# Note: Partial indexes are only supported for PostgreSQL and SQLite 3.8.0+.
|
534
|
+
#
|
533
535
|
# ====== Creating an index with a specific method
|
534
536
|
#
|
535
537
|
# add_index(:developers, :name, using: 'btree')
|
@@ -621,11 +623,21 @@ module ActiveRecord
|
|
621
623
|
indexes(table_name).detect { |i| i.name == index_name }
|
622
624
|
end
|
623
625
|
|
624
|
-
# Adds a reference.
|
625
|
-
#
|
626
|
-
# a
|
626
|
+
# Adds a reference. The reference column is an integer by default,
|
627
|
+
# the <tt>:type</tt> option can be used to specify a different type.
|
628
|
+
# Optionally adds a +_type+ column, if <tt>:polymorphic</tt> option is provided.
|
627
629
|
# <tt>add_reference</tt> and <tt>add_belongs_to</tt> are acceptable.
|
628
630
|
#
|
631
|
+
# The +options+ hash can include the following keys:
|
632
|
+
# [<tt>:type</tt>]
|
633
|
+
# The reference column type. Defaults to +:integer+.
|
634
|
+
# [<tt>:index</tt>]
|
635
|
+
# Add an appropriate index. Defaults to false.
|
636
|
+
# [<tt>:foreign_key</tt>]
|
637
|
+
# Add an appropriate foreign key. Defaults to false.
|
638
|
+
# [<tt>:polymorphic</tt>]
|
639
|
+
# Wether an additional +_type+ column should be added. Defaults to false.
|
640
|
+
#
|
629
641
|
# ====== Create a user_id integer column
|
630
642
|
#
|
631
643
|
# add_reference(:products, :user)
|
@@ -634,10 +646,6 @@ module ActiveRecord
|
|
634
646
|
#
|
635
647
|
# add_reference(:products, :user, type: :string)
|
636
648
|
#
|
637
|
-
# ====== Create a supplier_id and supplier_type columns
|
638
|
-
#
|
639
|
-
# add_belongs_to(:products, :supplier, polymorphic: true)
|
640
|
-
#
|
641
649
|
# ====== Create supplier_id, supplier_type columns and appropriate index
|
642
650
|
#
|
643
651
|
# add_reference(:products, :supplier, polymorphic: true, index: true)
|
@@ -655,7 +663,10 @@ module ActiveRecord
|
|
655
663
|
add_column(table_name, "#{ref_name}_id", type, options)
|
656
664
|
add_column(table_name, "#{ref_name}_type", :string, polymorphic.is_a?(Hash) ? polymorphic : options) if polymorphic
|
657
665
|
add_index(table_name, polymorphic ? %w[type id].map{ |t| "#{ref_name}_#{t}" } : "#{ref_name}_id", index_options.is_a?(Hash) ? index_options : {}) if index_options
|
658
|
-
|
666
|
+
if foreign_key_options
|
667
|
+
to_table = Base.pluralize_table_names ? ref_name.to_s.pluralize : ref_name
|
668
|
+
add_foreign_key(table_name, to_table, foreign_key_options.is_a?(Hash) ? foreign_key_options : {})
|
669
|
+
end
|
659
670
|
end
|
660
671
|
alias :add_belongs_to :add_reference
|
661
672
|
|
@@ -675,7 +686,10 @@ module ActiveRecord
|
|
675
686
|
# remove_reference(:products, :user, index: true, foreign_key: true)
|
676
687
|
#
|
677
688
|
def remove_reference(table_name, ref_name, options = {})
|
678
|
-
|
689
|
+
if options[:foreign_key]
|
690
|
+
to_table = Base.pluralize_table_names ? ref_name.to_s.pluralize : ref_name
|
691
|
+
remove_foreign_key(table_name, to_table)
|
692
|
+
end
|
679
693
|
|
680
694
|
remove_column(table_name, "#{ref_name}_id")
|
681
695
|
remove_column(table_name, "#{ref_name}_type") if options[:polymorphic]
|
@@ -692,8 +706,8 @@ module ActiveRecord
|
|
692
706
|
# +to_table+ contains the referenced primary key.
|
693
707
|
#
|
694
708
|
# The foreign key will be named after the following pattern: <tt>fk_rails_<identifier></tt>.
|
695
|
-
# +identifier+ is a 10 character long
|
696
|
-
# the <tt>:name</tt> option.
|
709
|
+
# +identifier+ is a 10 character long string which is deterministically generated from the
|
710
|
+
# +from_table+ and +column+. A custom name can be specified with the <tt>:name</tt> option.
|
697
711
|
#
|
698
712
|
# ====== Creating a simple foreign key
|
699
713
|
#
|
@@ -705,7 +719,7 @@ module ActiveRecord
|
|
705
719
|
#
|
706
720
|
# ====== Creating a foreign key on a specific column
|
707
721
|
#
|
708
|
-
# add_foreign_key :articles, :users, column: :author_id, primary_key:
|
722
|
+
# add_foreign_key :articles, :users, column: :author_id, primary_key: :lng_id
|
709
723
|
#
|
710
724
|
# generates:
|
711
725
|
#
|
@@ -874,7 +888,7 @@ module ActiveRecord
|
|
874
888
|
# add_timestamps(:suppliers, null: false)
|
875
889
|
#
|
876
890
|
def add_timestamps(table_name, options = {})
|
877
|
-
emit_warning_if_null_unspecified(options)
|
891
|
+
emit_warning_if_null_unspecified(:add_timestamps, options)
|
878
892
|
add_column table_name, :created_at, :datetime, options
|
879
893
|
add_column table_name, :updated_at, :datetime, options
|
880
894
|
end
|
@@ -58,6 +58,12 @@ module ActiveRecord
|
|
58
58
|
SchemaCreation.new self
|
59
59
|
end
|
60
60
|
|
61
|
+
def prepare_column_options(column, types) # :nodoc:
|
62
|
+
spec = super
|
63
|
+
spec.delete(:limit) if :boolean === column.type
|
64
|
+
spec
|
65
|
+
end
|
66
|
+
|
61
67
|
class Column < ConnectionAdapters::Column # :nodoc:
|
62
68
|
attr_reader :collation, :strict, :extra
|
63
69
|
|
@@ -57,7 +57,7 @@ module ActiveRecord
|
|
57
57
|
# * <tt>:database</tt> - The name of the database. No default, must be provided.
|
58
58
|
# * <tt>:encoding</tt> - (Optional) Sets the client encoding by executing "SET NAMES <encoding>" after connection.
|
59
59
|
# * <tt>:reconnect</tt> - Defaults to false (See MySQL documentation: http://dev.mysql.com/doc/refman/5.0/en/auto-reconnect.html).
|
60
|
-
# * <tt>:strict</tt> - Defaults to true. Enable STRICT_ALL_TABLES. (See MySQL documentation: http://dev.mysql.com/doc/refman/5.0/en/
|
60
|
+
# * <tt>:strict</tt> - Defaults to true. Enable STRICT_ALL_TABLES. (See MySQL documentation: http://dev.mysql.com/doc/refman/5.0/en/sql-mode.html)
|
61
61
|
# * <tt>:variables</tt> - (Optional) A hash session variables to send as <tt>SET @@SESSION.key = value</tt> on each database connection. Use the value +:default+ to set a variable to its DEFAULT value. (See MySQL documentation: http://dev.mysql.com/doc/refman/5.0/en/set-statement.html).
|
62
62
|
# * <tt>:sslca</tt> - Necessary to use MySQL with an SSL connection.
|
63
63
|
# * <tt>:sslkey</tt> - Necessary to use MySQL with an SSL connection.
|
@@ -15,11 +15,11 @@ module ActiveRecord
|
|
15
15
|
def run(records)
|
16
16
|
nodes = records.reject { |row| @store.key? row['oid'].to_i }
|
17
17
|
mapped, nodes = nodes.partition { |row| @store.key? row['typname'] }
|
18
|
-
ranges, nodes = nodes.partition { |row| row['typtype'] == 'r' }
|
19
|
-
enums, nodes = nodes.partition { |row| row['typtype'] == 'e' }
|
20
|
-
domains, nodes = nodes.partition { |row| row['typtype'] == 'd' }
|
21
|
-
arrays, nodes = nodes.partition { |row| row['typinput'] == 'array_in' }
|
22
|
-
composites, nodes = nodes.partition { |row| row['typelem'] !=
|
18
|
+
ranges, nodes = nodes.partition { |row| row['typtype'] == 'r'.freeze }
|
19
|
+
enums, nodes = nodes.partition { |row| row['typtype'] == 'e'.freeze }
|
20
|
+
domains, nodes = nodes.partition { |row| row['typtype'] == 'd'.freeze }
|
21
|
+
arrays, nodes = nodes.partition { |row| row['typinput'] == 'array_in'.freeze }
|
22
|
+
composites, nodes = nodes.partition { |row| row['typelem'].to_i != 0 }
|
23
23
|
|
24
24
|
mapped.each { |row| register_mapped_type(row) }
|
25
25
|
enums.each { |row| register_enum_type(row) }
|
@@ -29,6 +29,18 @@ module ActiveRecord
|
|
29
29
|
composites.each { |row| register_composite_type(row) }
|
30
30
|
end
|
31
31
|
|
32
|
+
def query_conditions_for_initial_load(type_map)
|
33
|
+
known_type_names = type_map.keys.map { |n| "'#{n}'" }
|
34
|
+
known_type_types = %w('r' 'e' 'd')
|
35
|
+
<<-SQL % [known_type_names.join(", "), known_type_types.join(", ")]
|
36
|
+
WHERE
|
37
|
+
t.typname IN (%s)
|
38
|
+
OR t.typtype IN (%s)
|
39
|
+
OR t.typinput::varchar = 'array_in'
|
40
|
+
OR t.typelem != 0
|
41
|
+
SQL
|
42
|
+
end
|
43
|
+
|
32
44
|
private
|
33
45
|
def register_mapped_type(row)
|
34
46
|
alias_type row['oid'], row['typname']
|
@@ -418,9 +418,7 @@ module ActiveRecord
|
|
418
418
|
rename_table_indexes(table_name, new_name)
|
419
419
|
end
|
420
420
|
|
421
|
-
|
422
|
-
# See TableDefinition#column for details of the options you can use.
|
423
|
-
def add_column(table_name, column_name, type, options = {})
|
421
|
+
def add_column(table_name, column_name, type, options = {}) #:nodoc:
|
424
422
|
clear_cache!
|
425
423
|
super
|
426
424
|
end
|
@@ -468,7 +466,7 @@ module ActiveRecord
|
|
468
466
|
end
|
469
467
|
|
470
468
|
# Renames a column in a table.
|
471
|
-
def rename_column(table_name, column_name, new_column_name)
|
469
|
+
def rename_column(table_name, column_name, new_column_name) #:nodoc:
|
472
470
|
clear_cache!
|
473
471
|
execute "ALTER TABLE #{quote_table_name(table_name)} RENAME COLUMN #{quote_column_name(column_name)} TO #{quote_column_name(new_column_name)}"
|
474
472
|
rename_column_indexes(table_name, column_name, new_column_name)
|
@@ -556,6 +556,8 @@ module ActiveRecord
|
|
556
556
|
end
|
557
557
|
|
558
558
|
def load_additional_types(type_map, oids = nil) # :nodoc:
|
559
|
+
initializer = OID::TypeMapInitializer.new(type_map)
|
560
|
+
|
559
561
|
if supports_ranges?
|
560
562
|
query = <<-SQL
|
561
563
|
SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype
|
@@ -571,11 +573,13 @@ module ActiveRecord
|
|
571
573
|
|
572
574
|
if oids
|
573
575
|
query += "WHERE t.oid::integer IN (%s)" % oids.join(", ")
|
576
|
+
else
|
577
|
+
query += initializer.query_conditions_for_initial_load(type_map)
|
574
578
|
end
|
575
579
|
|
576
|
-
|
577
|
-
|
578
|
-
|
580
|
+
execute_and_clear(query, 'SCHEMA', []) do |records|
|
581
|
+
initializer.run(records)
|
582
|
+
end
|
579
583
|
end
|
580
584
|
|
581
585
|
FEATURE_NOT_SUPPORTED = "0A000" #:nodoc:
|
data/lib/active_record/core.rb
CHANGED
@@ -281,18 +281,22 @@ module ActiveRecord
|
|
281
281
|
init_attributes(attributes, options) if attributes
|
282
282
|
|
283
283
|
yield self if block_given?
|
284
|
-
|
284
|
+
run_callbacks :initialize
|
285
285
|
end
|
286
286
|
|
287
|
-
# Initialize an empty model object from +coder+. +coder+
|
288
|
-
# the
|
289
|
-
#
|
287
|
+
# Initialize an empty model object from +coder+. +coder+ should be
|
288
|
+
# the result of previously encoding an Active Record model, using
|
289
|
+
# `encode_with`
|
290
290
|
#
|
291
291
|
# class Post < ActiveRecord::Base
|
292
292
|
# end
|
293
293
|
#
|
294
|
+
# old_post = Post.new(title: "hello world")
|
295
|
+
# coder = {}
|
296
|
+
# old_post.encode_with(coder)
|
297
|
+
#
|
294
298
|
# post = Post.allocate
|
295
|
-
# post.init_with(
|
299
|
+
# post.init_with(coder)
|
296
300
|
# post.title # => 'hello world'
|
297
301
|
def init_with(coder)
|
298
302
|
@attributes = coder['attributes']
|
@@ -303,8 +307,8 @@ module ActiveRecord
|
|
303
307
|
|
304
308
|
self.class.define_attribute_methods
|
305
309
|
|
306
|
-
|
307
|
-
|
310
|
+
run_callbacks :find
|
311
|
+
run_callbacks :initialize
|
308
312
|
|
309
313
|
self
|
310
314
|
end
|
@@ -340,7 +344,7 @@ module ActiveRecord
|
|
340
344
|
@attributes = @attributes.dup
|
341
345
|
@attributes.reset(self.class.primary_key)
|
342
346
|
|
343
|
-
|
347
|
+
run_callbacks(:initialize)
|
344
348
|
|
345
349
|
@aggregation_cache = {}
|
346
350
|
@association_cache = {}
|
@@ -479,16 +483,16 @@ module ActiveRecord
|
|
479
483
|
Hash[methods.map! { |method| [method, public_send(method)] }].with_indifferent_access
|
480
484
|
end
|
481
485
|
|
486
|
+
private
|
487
|
+
|
482
488
|
def set_transaction_state(state) # :nodoc:
|
483
489
|
@transaction_state = state
|
484
490
|
end
|
485
491
|
|
486
492
|
def has_transactional_callbacks? # :nodoc:
|
487
|
-
!_rollback_callbacks.empty? || !_commit_callbacks.empty?
|
493
|
+
!_rollback_callbacks.empty? || !_commit_callbacks.empty?
|
488
494
|
end
|
489
495
|
|
490
|
-
private
|
491
|
-
|
492
496
|
# Updates the attributes on this particular ActiveRecord object so that
|
493
497
|
# if it is associated with a transaction, then the state of the AR object
|
494
498
|
# will be updated to reflect the current state of the transaction
|
@@ -511,6 +515,8 @@ module ActiveRecord
|
|
511
515
|
end
|
512
516
|
|
513
517
|
def update_attributes_from_transaction_state(transaction_state, depth)
|
518
|
+
@reflects_state = [false] if depth == 0
|
519
|
+
|
514
520
|
if transaction_state && transaction_state.finalized? && !has_transactional_callbacks?
|
515
521
|
unless @reflects_state[depth]
|
516
522
|
restore_transaction_record_state if transaction_state.rolledback?
|
@@ -547,7 +553,6 @@ module ActiveRecord
|
|
547
553
|
@txn = nil
|
548
554
|
@_start_transaction_state = {}
|
549
555
|
@transaction_state = nil
|
550
|
-
@reflects_state = [false]
|
551
556
|
end
|
552
557
|
|
553
558
|
def initialize_internals_callback
|
data/lib/active_record/errors.rb
CHANGED
@@ -19,7 +19,7 @@ module ActiveRecord
|
|
19
19
|
# On the other hand, we want to monitor the performance of our real database
|
20
20
|
# queries, not the performance of the access to the query cache.
|
21
21
|
IGNORED_PAYLOADS = %w(SCHEMA EXPLAIN CACHE)
|
22
|
-
EXPLAINED_SQLS = /\A\s*(select|update|delete|insert)\b/i
|
22
|
+
EXPLAINED_SQLS = /\A\s*(with|select|update|delete|insert)\b/i
|
23
23
|
def ignore_payload?(payload)
|
24
24
|
payload[:exception] || IGNORED_PAYLOADS.include?(payload[:name]) || payload[:sql] !~ EXPLAINED_SQLS
|
25
25
|
end
|
@@ -534,12 +534,10 @@ module ActiveRecord
|
|
534
534
|
conn.insert_fixture(row, fixture_set_name)
|
535
535
|
end
|
536
536
|
end
|
537
|
-
end
|
538
537
|
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
connection.reset_pk_sequence!(fs.table_name)
|
538
|
+
# Cap primary key sequences to max(pk).
|
539
|
+
if conn.respond_to?(:reset_pk_sequence!)
|
540
|
+
conn.reset_pk_sequence!(fs.table_name)
|
543
541
|
end
|
544
542
|
end
|
545
543
|
end
|
@@ -661,7 +659,7 @@ module ActiveRecord
|
|
661
659
|
row[association.foreign_type] = $1
|
662
660
|
end
|
663
661
|
|
664
|
-
fk_type =
|
662
|
+
fk_type = reflection_class.columns_hash[fk_name].type
|
665
663
|
row[fk_name] = ActiveRecord::FixtureSet.identify(value, fk_type)
|
666
664
|
end
|
667
665
|
when :has_many
|
@@ -703,6 +701,10 @@ module ActiveRecord
|
|
703
701
|
def lhs_key
|
704
702
|
@association.through_reflection.foreign_key
|
705
703
|
end
|
704
|
+
|
705
|
+
def join_table
|
706
|
+
@association.through_reflection.table_name
|
707
|
+
end
|
706
708
|
end
|
707
709
|
|
708
710
|
private
|
@@ -307,9 +307,8 @@ module ActiveRecord
|
|
307
307
|
#
|
308
308
|
# == Reversible Migrations
|
309
309
|
#
|
310
|
-
# Starting with Rails 3.1, you will be able to define reversible migrations.
|
311
310
|
# Reversible migrations are migrations that know how to go +down+ for you.
|
312
|
-
# You simply supply the +up+ logic, and the Migration system
|
311
|
+
# You simply supply the +up+ logic, and the Migration system figures out
|
313
312
|
# how to execute the down commands for you.
|
314
313
|
#
|
315
314
|
# To define a reversible migration, define the +change+ method in your
|
@@ -139,7 +139,7 @@ module ActiveRecord
|
|
139
139
|
# Attributes marked as readonly are silently ignored if the record is
|
140
140
|
# being updated.
|
141
141
|
def save!(*)
|
142
|
-
create_or_update || raise(RecordNotSaved.new(
|
142
|
+
create_or_update || raise(RecordNotSaved.new("Failed to save the record", self))
|
143
143
|
end
|
144
144
|
|
145
145
|
# Deletes the record in the database and freezes this instance to
|
@@ -168,6 +168,7 @@ module ActiveRecord
|
|
168
168
|
def destroy
|
169
169
|
raise ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly?
|
170
170
|
destroy_associations
|
171
|
+
self.class.connection.add_transaction_record(self)
|
171
172
|
destroy_row if persisted?
|
172
173
|
@destroyed = true
|
173
174
|
freeze
|
@@ -181,7 +182,7 @@ module ActiveRecord
|
|
181
182
|
# and <tt>destroy!</tt> raises ActiveRecord::RecordNotDestroyed. See
|
182
183
|
# ActiveRecord::Callbacks for further details.
|
183
184
|
def destroy!
|
184
|
-
destroy || raise(
|
185
|
+
destroy || raise(RecordNotDestroyed.new("Failed to destroy the record", self))
|
185
186
|
end
|
186
187
|
|
187
188
|
# Returns an instance of the specified +klass+ with the attributes of the
|
@@ -368,7 +369,7 @@ module ActiveRecord
|
|
368
369
|
# # => #<Account id: 1, email: 'account@example.com'>
|
369
370
|
#
|
370
371
|
# Attributes are reloaded from the database, and caches busted, in
|
371
|
-
# particular the associations cache.
|
372
|
+
# particular the associations cache and the QueryCache.
|
372
373
|
#
|
373
374
|
# If the record no longer exists in the database <tt>ActiveRecord::RecordNotFound</tt>
|
374
375
|
# is raised. Otherwise, in addition to the in-place modification the method
|
@@ -406,6 +407,7 @@ module ActiveRecord
|
|
406
407
|
def reload(options = nil)
|
407
408
|
clear_aggregation_cache
|
408
409
|
clear_association_cache
|
410
|
+
self.class.connection.clear_query_cache
|
409
411
|
|
410
412
|
fresh_object =
|
411
413
|
if options && options[:lock]
|
@@ -240,7 +240,7 @@ db_namespace = namespace :db do
|
|
240
240
|
end
|
241
241
|
|
242
242
|
desc 'Load a schema.rb file into the database'
|
243
|
-
task :load => [:load_config] do
|
243
|
+
task :load => [:environment, :load_config] do
|
244
244
|
ActiveRecord::Tasks::DatabaseTasks.load_schema_current(:ruby, ENV['SCHEMA'])
|
245
245
|
end
|
246
246
|
|
@@ -196,7 +196,7 @@ module ActiveRecord
|
|
196
196
|
@scope = scope
|
197
197
|
@options = options
|
198
198
|
@active_record = active_record
|
199
|
-
@klass = options[:
|
199
|
+
@klass = options[:anonymous_class]
|
200
200
|
@plural_name = active_record.pluralize_table_names ?
|
201
201
|
name.to_s.pluralize : name.to_s
|
202
202
|
end
|
@@ -632,7 +632,7 @@ module ActiveRecord
|
|
632
632
|
|
633
633
|
def initialize(delegate_reflection)
|
634
634
|
@delegate_reflection = delegate_reflection
|
635
|
-
@klass = delegate_reflection.options[:
|
635
|
+
@klass = delegate_reflection.options[:anonymous_class]
|
636
636
|
@source_reflection_name = delegate_reflection.options[:source]
|
637
637
|
end
|
638
638
|
|