activerecord 2.3.2 → 2.3.3
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 +11 -0
- data/Rakefile +10 -10
- data/lib/active_record/associations.rb +67 -30
- data/lib/active_record/associations/association_collection.rb +9 -5
- data/lib/active_record/associations/association_proxy.rb +2 -2
- data/lib/active_record/associations/belongs_to_association.rb +22 -4
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +5 -1
- data/lib/active_record/associations/has_one_through_association.rb +8 -8
- data/lib/active_record/autosave_association.rb +11 -6
- data/lib/active_record/base.rb +16 -21
- data/lib/active_record/batches.rb +23 -15
- data/lib/active_record/calculations.rb +5 -13
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +66 -22
- data/lib/active_record/connection_adapters/sqlite_adapter.rb +3 -0
- data/lib/active_record/fixtures.rb +5 -4
- data/lib/active_record/named_scope.rb +2 -2
- data/lib/active_record/schema_dumper.rb +5 -1
- data/lib/active_record/serialization.rb +3 -2
- data/lib/active_record/serializers/json_serializer.rb +8 -18
- data/lib/active_record/session_store.rb +9 -1
- data/lib/active_record/timestamp.rb +39 -9
- data/lib/active_record/validations.rb +1 -1
- data/lib/active_record/version.rb +1 -1
- data/test/cases/associations/belongs_to_associations_test.rb +102 -4
- data/test/cases/associations/eager_test.rb +12 -0
- data/test/cases/associations/has_many_associations_test.rb +6 -0
- data/test/cases/associations/has_one_through_associations_test.rb +8 -1
- data/test/cases/associations/inner_join_association_test.rb +5 -0
- data/test/cases/autosave_association_test.rb +22 -0
- data/test/cases/base_test.rb +2 -2
- data/test/cases/calculations_test.rb +8 -14
- data/test/cases/copy_table_test_sqlite.rb +5 -5
- data/test/cases/finder_test.rb +6 -0
- data/test/cases/fixtures_test.rb +5 -0
- data/test/cases/helper.rb +1 -2
- data/test/cases/json_serialization_test.rb +57 -57
- data/test/cases/method_scoping_test.rb +13 -3
- data/test/cases/reflection_test.rb +5 -5
- data/test/cases/schema_dumper_test.rb +17 -7
- data/test/cases/schema_test_postgresql.rb +76 -0
- data/test/cases/timestamp_test.rb +75 -0
- data/test/debug.log +415 -0
- data/test/fixtures/fixture_database.sqlite3 +0 -0
- data/test/fixtures/fixture_database_2.sqlite3 +0 -0
- data/test/models/author.rb +4 -0
- data/test/models/company.rb +7 -7
- data/test/models/developer.rb +10 -0
- data/test/models/essay.rb +3 -0
- data/test/models/pet.rb +1 -1
- data/test/models/project.rb +1 -1
- data/test/models/reply.rb +2 -1
- data/test/models/topic.rb +1 -0
- data/test/models/toy.rb +2 -0
- data/test/schema/schema.rb +15 -0
- metadata +6 -3
Binary file
|
Binary file
|
data/test/models/author.rb
CHANGED
@@ -25,6 +25,8 @@ class Author < ActiveRecord::Base
|
|
25
25
|
has_many :comments_with_order_and_conditions, :through => :posts, :source => :comments, :order => 'comments.body', :conditions => "comments.body like 'Thank%'"
|
26
26
|
has_many :comments_with_include, :through => :posts, :source => :comments, :include => :post
|
27
27
|
|
28
|
+
has_many :thinking_posts, :class_name => 'Post', :conditions => { :title => 'So I was thinking' }, :dependent => :delete_all
|
29
|
+
has_many :welcome_posts, :class_name => 'Post', :conditions => { :title => 'Welcome to the weblog' }
|
28
30
|
|
29
31
|
has_many :comments_desc, :through => :posts, :source => :comments, :order => 'comments.id DESC'
|
30
32
|
has_many :limited_comments, :through => :posts, :source => :comments, :limit => 1
|
@@ -85,6 +87,8 @@ class Author < ActiveRecord::Base
|
|
85
87
|
has_many :tags, :through => :posts # through has_many :through
|
86
88
|
has_many :post_categories, :through => :posts, :source => :categories
|
87
89
|
|
90
|
+
has_one :essay, :primary_key => :name, :as => :writer
|
91
|
+
|
88
92
|
belongs_to :author_address, :dependent => :destroy
|
89
93
|
belongs_to :author_address_extra, :dependent => :delete, :class_name => "AuthorAddress"
|
90
94
|
|
data/test/models/company.rb
CHANGED
@@ -78,19 +78,13 @@ class DependentFirm < Company
|
|
78
78
|
has_many :companies, :foreign_key => 'client_of', :order => "id", :dependent => :nullify
|
79
79
|
end
|
80
80
|
|
81
|
-
class ExclusivelyDependentFirm < Company
|
82
|
-
has_one :account, :foreign_key => "firm_id", :dependent => :delete
|
83
|
-
has_many :dependent_sanitized_conditional_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all, :conditions => "name = 'BigShot Inc.'"
|
84
|
-
has_many :dependent_conditional_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all, :conditions => ["name = ?", 'BigShot Inc.']
|
85
|
-
has_many :dependent_hash_conditional_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all, :conditions => {:name => 'BigShot Inc.'}
|
86
|
-
end
|
87
|
-
|
88
81
|
class Client < Company
|
89
82
|
belongs_to :firm, :foreign_key => "client_of"
|
90
83
|
belongs_to :firm_with_basic_id, :class_name => "Firm", :foreign_key => "firm_id"
|
91
84
|
belongs_to :firm_with_select, :class_name => "Firm", :foreign_key => "firm_id", :select => "id"
|
92
85
|
belongs_to :firm_with_other_name, :class_name => "Firm", :foreign_key => "client_of"
|
93
86
|
belongs_to :firm_with_condition, :class_name => "Firm", :foreign_key => "client_of", :conditions => ["1 = ?", 1]
|
87
|
+
belongs_to :firm_with_primary_key, :class_name => "Firm", :primary_key => "name", :foreign_key => "firm_name"
|
94
88
|
belongs_to :readonly_firm, :class_name => "Firm", :foreign_key => "firm_id", :readonly => true
|
95
89
|
|
96
90
|
# Record destruction so we can test whether firm.clients.clear has
|
@@ -125,6 +119,12 @@ class Client < Company
|
|
125
119
|
end
|
126
120
|
end
|
127
121
|
|
122
|
+
class ExclusivelyDependentFirm < Company
|
123
|
+
has_one :account, :foreign_key => "firm_id", :dependent => :delete
|
124
|
+
has_many :dependent_sanitized_conditional_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all, :conditions => "name = 'BigShot Inc.'"
|
125
|
+
has_many :dependent_conditional_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all, :conditions => ["name = ?", 'BigShot Inc.']
|
126
|
+
has_many :dependent_hash_conditional_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all, :conditions => {:name => 'BigShot Inc.'}
|
127
|
+
end
|
128
128
|
|
129
129
|
class SpecialClient < Client
|
130
130
|
end
|
data/test/models/developer.rb
CHANGED
@@ -89,3 +89,13 @@ class DeveloperOrderedBySalary < ActiveRecord::Base
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
end
|
92
|
+
|
93
|
+
class DeveloperCalledDavid < ActiveRecord::Base
|
94
|
+
self.table_name = 'developers'
|
95
|
+
default_scope :conditions => "name = 'David'"
|
96
|
+
end
|
97
|
+
|
98
|
+
class DeveloperCalledJamis < ActiveRecord::Base
|
99
|
+
self.table_name = 'developers'
|
100
|
+
default_scope :conditions => { :name => 'Jamis' }
|
101
|
+
end
|
data/test/models/pet.rb
CHANGED
data/test/models/project.rb
CHANGED
@@ -13,7 +13,7 @@ class Project < ActiveRecord::Base
|
|
13
13
|
:after_add => Proc.new {|o, r| o.developers_log << "after_adding#{r.id || '<new>'}"},
|
14
14
|
:before_remove => Proc.new {|o, r| o.developers_log << "before_removing#{r.id}"},
|
15
15
|
:after_remove => Proc.new {|o, r| o.developers_log << "after_removing#{r.id}"}
|
16
|
-
has_and_belongs_to_many :well_payed_salary_groups, :class_name => "Developer", :group => "salary", :having => "SUM(salary) > 10000", :select => "SUM(salary) as salary"
|
16
|
+
has_and_belongs_to_many :well_payed_salary_groups, :class_name => "Developer", :group => "developers.salary", :having => "SUM(salary) > 10000", :select => "SUM(salary) as salary"
|
17
17
|
|
18
18
|
attr_accessor :developers_log
|
19
19
|
|
data/test/models/reply.rb
CHANGED
@@ -4,12 +4,13 @@ class Reply < Topic
|
|
4
4
|
named_scope :base
|
5
5
|
|
6
6
|
belongs_to :topic, :foreign_key => "parent_id", :counter_cache => true
|
7
|
+
belongs_to :topic_with_primary_key, :class_name => "Topic", :primary_key => "title", :foreign_key => "parent_title", :counter_cache => "replies_count"
|
7
8
|
has_many :replies, :class_name => "SillyReply", :dependent => :destroy, :foreign_key => "parent_id"
|
8
9
|
|
9
10
|
validate :errors_on_empty_content
|
10
11
|
validate_on_create :title_is_wrong_create
|
11
12
|
|
12
|
-
attr_accessible :title, :author_name, :author_email_address, :written_on, :content, :last_read
|
13
|
+
attr_accessible :title, :author_name, :author_email_address, :written_on, :content, :last_read, :parent_title
|
13
14
|
|
14
15
|
def validate
|
15
16
|
errors.add("title", "Empty") unless attribute_present? "title"
|
data/test/models/topic.rb
CHANGED
@@ -39,6 +39,7 @@ class Topic < ActiveRecord::Base
|
|
39
39
|
named_scope :by_rejected_ids, lambda {{ :conditions => { :id => all(:conditions => {:approved => false}).map(&:id) } }}
|
40
40
|
|
41
41
|
has_many :replies, :dependent => :destroy, :foreign_key => "parent_id"
|
42
|
+
has_many :replies_with_primary_key, :class_name => "Reply", :dependent => :destroy, :primary_key => "title", :foreign_key => "parent_title"
|
42
43
|
serialize :content
|
43
44
|
|
44
45
|
before_create :default_written_on
|
data/test/models/toy.rb
CHANGED
data/test/schema/schema.rb
CHANGED
@@ -68,6 +68,10 @@ ActiveRecord::Schema.define do
|
|
68
68
|
t.boolean :value
|
69
69
|
end
|
70
70
|
|
71
|
+
create_table "CamelCase", :force => true do |t|
|
72
|
+
t.string :name
|
73
|
+
end
|
74
|
+
|
71
75
|
create_table :categories, :force => true do |t|
|
72
76
|
t.string :name, :null => false
|
73
77
|
t.string :type
|
@@ -114,6 +118,8 @@ ActiveRecord::Schema.define do
|
|
114
118
|
t.integer :rating, :default => 1
|
115
119
|
end
|
116
120
|
|
121
|
+
add_index :companies, [:firm_id, :type, :rating, :ruby_type], :name => "company_index"
|
122
|
+
|
117
123
|
create_table :computers, :force => true do |t|
|
118
124
|
t.integer :developer, :null => false
|
119
125
|
t.integer :extendedWarranty, :null => false
|
@@ -155,6 +161,12 @@ ActiveRecord::Schema.define do
|
|
155
161
|
t.integer :course_id, :null => false
|
156
162
|
end
|
157
163
|
|
164
|
+
create_table :essays, :force => true do |t|
|
165
|
+
t.string :name
|
166
|
+
t.string :writer_id
|
167
|
+
t.string :writer_type
|
168
|
+
end
|
169
|
+
|
158
170
|
create_table :events, :force => true do |t|
|
159
171
|
t.string :title, :limit => 5
|
160
172
|
end
|
@@ -281,6 +293,8 @@ ActiveRecord::Schema.define do
|
|
281
293
|
|
282
294
|
create_table :owners, :primary_key => :owner_id ,:force => true do |t|
|
283
295
|
t.string :name
|
296
|
+
t.column :updated_at, :datetime
|
297
|
+
t.column :happy_at, :datetime
|
284
298
|
end
|
285
299
|
|
286
300
|
|
@@ -410,6 +424,7 @@ ActiveRecord::Schema.define do
|
|
410
424
|
t.boolean :approved, :default => true
|
411
425
|
t.integer :replies_count, :default => 0
|
412
426
|
t.integer :parent_id
|
427
|
+
t.string :parent_title
|
413
428
|
t.string :type
|
414
429
|
end
|
415
430
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -9,7 +9,7 @@ autorequire: active_record
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-07-20 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - "="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 2.3.
|
23
|
+
version: 2.3.3
|
24
24
|
version:
|
25
25
|
description: Implements the ActiveRecord pattern (Fowler, PoEAA) for ORM. It ties database tables and classes together for business objects, like Customer or Subscription, that can find, save, and destroy themselves without resorting to manual SQL.
|
26
26
|
email: david@loudthinking.com
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- test/cases/schema_test_postgresql.rb
|
182
182
|
- test/cases/serialization_test.rb
|
183
183
|
- test/cases/synonym_test_oracle.rb
|
184
|
+
- test/cases/timestamp_test.rb
|
184
185
|
- test/cases/transactions_test.rb
|
185
186
|
- test/cases/unconnected_test.rb
|
186
187
|
- test/cases/validations_i18n_test.rb
|
@@ -221,6 +222,7 @@ files:
|
|
221
222
|
- test/connections/native_sqlite3/in_memory_connection.rb
|
222
223
|
- test/connections/native_sybase
|
223
224
|
- test/connections/native_sybase/connection.rb
|
225
|
+
- test/debug.log
|
224
226
|
- test/fixtures
|
225
227
|
- test/fixtures/accounts.yml
|
226
228
|
- test/fixtures/all
|
@@ -357,6 +359,7 @@ files:
|
|
357
359
|
- test/models/developer.rb
|
358
360
|
- test/models/edge.rb
|
359
361
|
- test/models/entrant.rb
|
362
|
+
- test/models/essay.rb
|
360
363
|
- test/models/event.rb
|
361
364
|
- test/models/guid.rb
|
362
365
|
- test/models/item.rb
|