activerecord 3.0.0.rc → 3.0.0.rc2
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 +6 -1
- data/README.rdoc +9 -9
- data/lib/active_record/aggregations.rb +64 -51
- data/lib/active_record/association_preload.rb +11 -9
- data/lib/active_record/associations.rb +300 -204
- data/lib/active_record/associations/association_collection.rb +7 -2
- data/lib/active_record/associations/belongs_to_association.rb +9 -5
- data/lib/active_record/associations/has_and_belongs_to_many_association.rb +7 -6
- data/lib/active_record/associations/has_many_association.rb +6 -6
- data/lib/active_record/associations/has_many_through_association.rb +4 -3
- data/lib/active_record/associations/has_one_association.rb +7 -7
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +2 -1
- data/lib/active_record/attribute_methods/write.rb +2 -2
- data/lib/active_record/autosave_association.rb +54 -72
- data/lib/active_record/base.rb +167 -108
- data/lib/active_record/callbacks.rb +43 -35
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +8 -11
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +0 -8
- data/lib/active_record/connection_adapters/abstract/quoting.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +8 -6
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +5 -3
- data/lib/active_record/connection_adapters/mysql_adapter.rb +5 -1
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +9 -5
- data/lib/active_record/connection_adapters/sqlite_adapter.rb +5 -5
- data/lib/active_record/dynamic_finder_match.rb +3 -3
- data/lib/active_record/dynamic_scope_match.rb +1 -1
- data/lib/active_record/errors.rb +9 -5
- data/lib/active_record/fixtures.rb +36 -22
- data/lib/active_record/locale/en.yml +2 -2
- data/lib/active_record/migration.rb +36 -36
- data/lib/active_record/named_scope.rb +23 -11
- data/lib/active_record/nested_attributes.rb +3 -3
- data/lib/active_record/observer.rb +3 -3
- data/lib/active_record/persistence.rb +44 -29
- data/lib/active_record/railtie.rb +5 -8
- data/lib/active_record/railties/databases.rake +1 -1
- data/lib/active_record/reflection.rb +52 -52
- data/lib/active_record/relation.rb +26 -19
- data/lib/active_record/relation/batches.rb +4 -4
- data/lib/active_record/relation/calculations.rb +58 -34
- data/lib/active_record/relation/finder_methods.rb +21 -12
- data/lib/active_record/relation/query_methods.rb +26 -31
- data/lib/active_record/relation/spawn_methods.rb +17 -5
- data/lib/active_record/schema.rb +1 -1
- data/lib/active_record/schema_dumper.rb +12 -12
- data/lib/active_record/serialization.rb +1 -1
- data/lib/active_record/serializers/xml_serializer.rb +1 -1
- data/lib/active_record/session_store.rb +9 -9
- data/lib/active_record/test_case.rb +2 -2
- data/lib/active_record/timestamp.rb +31 -32
- data/lib/active_record/validations/associated.rb +4 -3
- data/lib/active_record/validations/uniqueness.rb +15 -11
- data/lib/active_record/version.rb +1 -1
- metadata +17 -16
@@ -27,8 +27,9 @@ module ActiveRecord
|
|
27
27
|
#
|
28
28
|
# this would specify a circular dependency and cause infinite recursion.
|
29
29
|
#
|
30
|
-
# NOTE: This validation will not fail if the association hasn't been assigned. If you want to
|
31
|
-
# is both present and guaranteed to be valid, you also need to
|
30
|
+
# NOTE: This validation will not fail if the association hasn't been assigned. If you want to
|
31
|
+
# ensure that the association is both present and guaranteed to be valid, you also need to
|
32
|
+
# use +validates_presence_of+.
|
32
33
|
#
|
33
34
|
# Configuration options:
|
34
35
|
# * <tt>:message</tt> - A custom error message (default is: "is invalid")
|
@@ -44,4 +45,4 @@ module ActiveRecord
|
|
44
45
|
end
|
45
46
|
end
|
46
47
|
end
|
47
|
-
end
|
48
|
+
end
|
@@ -78,22 +78,25 @@ module ActiveRecord
|
|
78
78
|
end
|
79
79
|
|
80
80
|
module ClassMethods
|
81
|
-
# Validates whether the value of the specified attributes are unique across the system.
|
81
|
+
# Validates whether the value of the specified attributes are unique across the system.
|
82
|
+
# Useful for making sure that only one user
|
82
83
|
# can be named "davidhh".
|
83
84
|
#
|
84
85
|
# class Person < ActiveRecord::Base
|
85
86
|
# validates_uniqueness_of :user_name, :scope => :account_id
|
86
87
|
# end
|
87
88
|
#
|
88
|
-
# It can also validate whether the value of the specified attributes are unique based on multiple
|
89
|
-
# making sure that a teacher can only be on the schedule once
|
89
|
+
# It can also validate whether the value of the specified attributes are unique based on multiple
|
90
|
+
# scope parameters. For example, making sure that a teacher can only be on the schedule once
|
91
|
+
# per semester for a particular class.
|
90
92
|
#
|
91
93
|
# class TeacherSchedule < ActiveRecord::Base
|
92
94
|
# validates_uniqueness_of :teacher_id, :scope => [:semester_id, :class_id]
|
93
95
|
# end
|
94
96
|
#
|
95
|
-
# When the record is created, a check is performed to make sure that no record exists in the database
|
96
|
-
# attribute (that maps to a column). When the record is updated,
|
97
|
+
# When the record is created, a check is performed to make sure that no record exists in the database
|
98
|
+
# with the given value for the specified attribute (that maps to a column). When the record is updated,
|
99
|
+
# the same check is made but disregarding the record itself.
|
97
100
|
#
|
98
101
|
# Configuration options:
|
99
102
|
# * <tt>:message</tt> - Specifies a custom error message (default is: "has already been taken").
|
@@ -102,11 +105,12 @@ module ActiveRecord
|
|
102
105
|
# * <tt>:allow_nil</tt> - If set to true, skips this validation if the attribute is +nil+ (default is +false+).
|
103
106
|
# * <tt>:allow_blank</tt> - If set to true, skips this validation if the attribute is blank (default is +false+).
|
104
107
|
# * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should
|
105
|
-
# occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>).
|
106
|
-
# method, proc or string should return or evaluate to a true or false value.
|
108
|
+
# occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>).
|
109
|
+
# The method, proc or string should return or evaluate to a true or false value.
|
107
110
|
# * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should
|
108
|
-
# not occur (e.g. <tt>:unless => :skip_validation</tt>, or
|
109
|
-
#
|
111
|
+
# not occur (e.g. <tt>:unless => :skip_validation</tt>, or
|
112
|
+
# <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The method, proc or string should
|
113
|
+
# return or evaluate to a true or false value.
|
110
114
|
#
|
111
115
|
# === Concurrency and integrity
|
112
116
|
#
|
@@ -158,7 +162,7 @@ module ActiveRecord
|
|
158
162
|
# ActiveRecord::ConnectionAdapters::SchemaStatements#add_index. In the
|
159
163
|
# rare case that a race condition occurs, the database will guarantee
|
160
164
|
# the field's uniqueness.
|
161
|
-
#
|
165
|
+
#
|
162
166
|
# When the database catches such a duplicate insertion,
|
163
167
|
# ActiveRecord::Base#save will raise an ActiveRecord::StatementInvalid
|
164
168
|
# exception. You can either choose to let this error propagate (which
|
@@ -167,7 +171,7 @@ module ActiveRecord
|
|
167
171
|
# that the title already exists, and asking him to re-enter the title).
|
168
172
|
# This technique is also known as optimistic concurrency control:
|
169
173
|
# http://en.wikipedia.org/wiki/Optimistic_concurrency_control
|
170
|
-
#
|
174
|
+
#
|
171
175
|
# Active Record currently provides no way to distinguish unique
|
172
176
|
# index constraint errors from other types of database errors, so you
|
173
177
|
# will have to parse the (database-specific) exception message to detect
|
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: 977940607
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
9
|
- 0
|
10
|
-
-
|
11
|
-
version: 3.0.0.
|
10
|
+
- rc2
|
11
|
+
version: 3.0.0.rc2
|
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: 2010-
|
19
|
+
date: 2010-08-23 00:00:00 -05: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: 977940607
|
31
31
|
segments:
|
32
32
|
- 3
|
33
33
|
- 0
|
34
34
|
- 0
|
35
|
-
-
|
36
|
-
version: 3.0.0.
|
35
|
+
- rc2
|
36
|
+
version: 3.0.0.rc2
|
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: 977940607
|
48
48
|
segments:
|
49
49
|
- 3
|
50
50
|
- 0
|
51
51
|
- 0
|
52
|
-
-
|
53
|
-
version: 3.0.0.
|
52
|
+
- rc2
|
53
|
+
version: 3.0.0.rc2
|
54
54
|
type: :runtime
|
55
55
|
version_requirements: *id002
|
56
56
|
- !ruby/object:Gem::Dependency
|
@@ -61,12 +61,13 @@ dependencies:
|
|
61
61
|
requirements:
|
62
62
|
- - ~>
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
hash:
|
64
|
+
hash: 977940574
|
65
65
|
segments:
|
66
|
+
- 1
|
66
67
|
- 0
|
67
|
-
- 4
|
68
68
|
- 0
|
69
|
-
|
69
|
+
- rc1
|
70
|
+
version: 1.0.0.rc1
|
70
71
|
type: :runtime
|
71
72
|
version_requirements: *id003
|
72
73
|
- !ruby/object:Gem::Dependency
|
@@ -77,12 +78,12 @@ dependencies:
|
|
77
78
|
requirements:
|
78
79
|
- - ~>
|
79
80
|
- !ruby/object:Gem::Version
|
80
|
-
hash:
|
81
|
+
hash: 61
|
81
82
|
segments:
|
82
83
|
- 0
|
83
84
|
- 3
|
84
|
-
-
|
85
|
-
version: 0.3.
|
85
|
+
- 23
|
86
|
+
version: 0.3.23
|
86
87
|
type: :runtime
|
87
88
|
version_requirements: *id004
|
88
89
|
description: Databases on Rails. Build a persistent domain model by mapping database tables to Ruby classes. Strong conventions for associations, validations, aggregations, migrations, and testing come baked-in.
|