activerecord 3.1.1.rc2 → 3.1.1.rc3
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.
- data/CHANGELOG +5 -0
- data/lib/active_record/errors.rb +13 -0
- data/lib/active_record/railties/databases.rake +1 -1
- data/lib/active_record/reflection.rb +8 -4
- data/lib/active_record/version.rb +1 -1
- metadata +10 -10
data/CHANGELOG
CHANGED
data/lib/active_record/errors.rb
CHANGED
@@ -169,4 +169,17 @@ module ActiveRecord
|
|
169
169
|
@errors = errors
|
170
170
|
end
|
171
171
|
end
|
172
|
+
|
173
|
+
# Raised when a primary key is needed, but there is not one specified in the schema or model.
|
174
|
+
class UnknownPrimaryKey < ActiveRecordError
|
175
|
+
attr_reader :model
|
176
|
+
|
177
|
+
def initialize(model)
|
178
|
+
@model = model
|
179
|
+
end
|
180
|
+
|
181
|
+
def message
|
182
|
+
"Unknown primary key for table #{model.table_name} in model #{model}."
|
183
|
+
end
|
184
|
+
end
|
172
185
|
end
|
@@ -341,7 +341,7 @@ db_namespace = namespace :db do
|
|
341
341
|
|
342
342
|
namespace :schema do
|
343
343
|
desc 'Create a db/schema.rb file that can be portably used against any DB supported by AR'
|
344
|
-
task :dump => :load_config do
|
344
|
+
task :dump => [:environment, :load_config] do
|
345
345
|
require 'active_record/schema_dumper'
|
346
346
|
filename = ENV['SCHEMA'] || "#{Rails.root}/db/schema.rb"
|
347
347
|
File.open(filename, "w:utf-8") do |file|
|
@@ -225,11 +225,11 @@ module ActiveRecord
|
|
225
225
|
|
226
226
|
# klass option is necessary to support loading polymorphic associations
|
227
227
|
def association_primary_key(klass = nil)
|
228
|
-
options[:primary_key] || (klass || self.klass)
|
228
|
+
options[:primary_key] || primary_key(klass || self.klass)
|
229
229
|
end
|
230
230
|
|
231
231
|
def active_record_primary_key
|
232
|
-
@active_record_primary_key ||= options[:primary_key] || active_record
|
232
|
+
@active_record_primary_key ||= options[:primary_key] || primary_key(active_record)
|
233
233
|
end
|
234
234
|
|
235
235
|
def counter_cache_column
|
@@ -369,6 +369,10 @@ module ActiveRecord
|
|
369
369
|
active_record.name.foreign_key
|
370
370
|
end
|
371
371
|
end
|
372
|
+
|
373
|
+
def primary_key(klass)
|
374
|
+
klass.primary_key || raise(UnknownPrimaryKey.new(klass))
|
375
|
+
end
|
372
376
|
end
|
373
377
|
|
374
378
|
# Holds all the meta-data about a :through association as it was specified
|
@@ -473,7 +477,7 @@ module ActiveRecord
|
|
473
477
|
# We want to use the klass from this reflection, rather than just delegate straight to
|
474
478
|
# the source_reflection, because the source_reflection may be polymorphic. We still
|
475
479
|
# need to respect the source_reflection's :primary_key option, though.
|
476
|
-
def association_primary_key(klass =
|
480
|
+
def association_primary_key(klass = nil)
|
477
481
|
# Get the "actual" source reflection if the immediate source reflection has a
|
478
482
|
# source reflection itself
|
479
483
|
source_reflection = self.source_reflection
|
@@ -481,7 +485,7 @@ module ActiveRecord
|
|
481
485
|
source_reflection = source_reflection.source_reflection
|
482
486
|
end
|
483
487
|
|
484
|
-
source_reflection.options[:primary_key] || klass.
|
488
|
+
source_reflection.options[:primary_key] || primary_key(klass || self.klass)
|
485
489
|
end
|
486
490
|
|
487
491
|
# Gets an array of possible <tt>:through</tt> source reflection names:
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 977940592
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 1
|
9
9
|
- 1
|
10
|
-
-
|
11
|
-
version: 3.1.1.
|
10
|
+
- rc3
|
11
|
+
version: 3.1.1.rc3
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- David Heinemeier Hansson
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-10-05 00:00:00 -02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -27,13 +27,13 @@ dependencies:
|
|
27
27
|
requirements:
|
28
28
|
- - "="
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
hash:
|
30
|
+
hash: 977940592
|
31
31
|
segments:
|
32
32
|
- 3
|
33
33
|
- 1
|
34
34
|
- 1
|
35
|
-
-
|
36
|
-
version: 3.1.1.
|
35
|
+
- rc3
|
36
|
+
version: 3.1.1.rc3
|
37
37
|
type: :runtime
|
38
38
|
version_requirements: *id001
|
39
39
|
- !ruby/object:Gem::Dependency
|
@@ -44,13 +44,13 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
hash:
|
47
|
+
hash: 977940592
|
48
48
|
segments:
|
49
49
|
- 3
|
50
50
|
- 1
|
51
51
|
- 1
|
52
|
-
-
|
53
|
-
version: 3.1.1.
|
52
|
+
- rc3
|
53
|
+
version: 3.1.1.rc3
|
54
54
|
type: :runtime
|
55
55
|
version_requirements: *id002
|
56
56
|
- !ruby/object:Gem::Dependency
|