activerecord 3.1.0 → 3.1.1.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.

@@ -71,7 +71,7 @@ module ActiveRecord
71
71
  end
72
72
 
73
73
  def invert_rename_index(args)
74
- [:rename_index, args.reverse]
74
+ [:rename_index, [args.first] + args.last(2).reverse]
75
75
  end
76
76
 
77
77
  def invert_rename_column(args)
@@ -203,11 +203,13 @@ db_namespace = namespace :db do
203
203
  end
204
204
  db_list = ActiveRecord::Base.connection.select_values("SELECT version FROM #{ActiveRecord::Migrator.schema_migrations_table_name}")
205
205
  file_list = []
206
- Dir.foreach(File.join(Rails.root, 'db', 'migrate')) do |file|
207
- # only files matching "20091231235959_some_name.rb" pattern
208
- if match_data = /^(\d{14})_(.+)\.rb$/.match(file)
209
- status = db_list.delete(match_data[1]) ? 'up' : 'down'
210
- file_list << [status, match_data[1], match_data[2].humanize]
206
+ ActiveRecord::Migrator.migrations_paths.each do |path|
207
+ Dir.foreach(path) do |file|
208
+ # only files matching "20091231235959_some_name.rb" pattern
209
+ if match_data = /^(\d{14})_(.+)\.rb$/.match(file)
210
+ status = db_list.delete(match_data[1]) ? 'up' : 'down'
211
+ file_list << [status, match_data[1], match_data[2].humanize]
212
+ end
211
213
  end
212
214
  end
213
215
  db_list.map! do |version|
@@ -238,7 +238,7 @@ module ActiveRecord
238
238
  if options[:counter_cache] == true
239
239
  "#{active_record.name.demodulize.underscore.pluralize}_count"
240
240
  elsif options[:counter_cache]
241
- options[:counter_cache]
241
+ options[:counter_cache].to_s
242
242
  end
243
243
  end
244
244
 
@@ -62,7 +62,7 @@ module ActiveRecord
62
62
  start = options.delete(:start).to_i
63
63
  batch_size = options.delete(:batch_size) || 1000
64
64
 
65
- relation = relation.except(:order).order(batch_order).limit(batch_size)
65
+ relation = relation.reorder(batch_order).limit(batch_size)
66
66
  records = relation.where(table[primary_key].gteq(start)).all
67
67
 
68
68
  while records.any?
@@ -246,6 +246,7 @@ module ActiveRecord
246
246
  operation,
247
247
  distinct).as(aggregate_alias)
248
248
  ]
249
+ select_values += @select_values unless @having_values.empty?
249
250
 
250
251
  select_values.concat group_fields.zip(group_aliases).map { |field,aliaz|
251
252
  "#{field} AS #{aliaz}"
@@ -114,7 +114,7 @@ module ActiveRecord
114
114
  def first(*args)
115
115
  if args.any?
116
116
  if args.first.kind_of?(Integer) || (loaded? && !args.first.kind_of?(Hash))
117
- to_a.first(*args)
117
+ limit(*args).to_a
118
118
  else
119
119
  apply_finder_options(args.first).first
120
120
  end
@@ -134,7 +134,11 @@ module ActiveRecord
134
134
  def last(*args)
135
135
  if args.any?
136
136
  if args.first.kind_of?(Integer) || (loaded? && !args.first.kind_of?(Hash))
137
- to_a.last(*args)
137
+ if order_values.empty? && reorder_value.nil?
138
+ order("#{primary_key} DESC").limit(*args).reverse
139
+ else
140
+ to_a.last(*args)
141
+ end
138
142
  else
139
143
  apply_finder_options(args.first).last
140
144
  end
@@ -180,7 +184,9 @@ module ActiveRecord
180
184
  # Person.exists?(:name => "David")
181
185
  # Person.exists?(['name LIKE ?', "%#{query}%"])
182
186
  # Person.exists?
183
- def exists?(id = nil)
187
+ def exists?(id = false)
188
+ return false if id.nil?
189
+
184
190
  id = id.id if ActiveRecord::Base === id
185
191
 
186
192
  join_dependency = construct_join_dependency_for_association_find
@@ -254,12 +254,12 @@ module ActiveRecord
254
254
 
255
255
  association_joins = buckets['association_join'] || []
256
256
  stashed_association_joins = buckets['stashed_join'] || []
257
- join_nodes = buckets['join_node'] || []
257
+ join_nodes = (buckets['join_node'] || []).uniq
258
258
  string_joins = (buckets['string_join'] || []).map { |x|
259
259
  x.strip
260
260
  }.uniq
261
261
 
262
- join_list = custom_join_ast(manager, string_joins)
262
+ join_list = join_nodes + custom_join_ast(manager, string_joins)
263
263
 
264
264
  join_dependency = ActiveRecord::Associations::JoinDependency.new(
265
265
  @klass,
@@ -267,10 +267,6 @@ module ActiveRecord
267
267
  join_list
268
268
  )
269
269
 
270
- join_nodes.each do |join|
271
- join_dependency.alias_tracker.aliased_name_for(join.left.name.downcase)
272
- end
273
-
274
270
  join_dependency.graft(*stashed_association_joins)
275
271
 
276
272
  @implicit_readonly = true unless association_joins.empty? && stashed_association_joins.empty?
@@ -280,7 +276,6 @@ module ActiveRecord
280
276
  association.join_to(manager)
281
277
  end
282
278
 
283
- manager.join_sources.concat join_nodes.uniq
284
279
  manager.join_sources.concat join_list
285
280
 
286
281
  manager
@@ -2,8 +2,8 @@ module ActiveRecord
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
- TINY = 0
6
- PRE = nil
5
+ TINY = 1
6
+ PRE = "rc1"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
9
9
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
5
- prerelease:
4
+ hash: 977940594
5
+ prerelease: true
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
- - 0
10
- version: 3.1.0
9
+ - 1
10
+ - rc1
11
+ version: 3.1.1.rc1
11
12
  platform: ruby
12
13
  authors:
13
14
  - David Heinemeier Hansson
@@ -15,7 +16,8 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-08-31 00:00:00 Z
19
+ date: 2011-09-14 00:00:00 -07:00
20
+ default_executable:
19
21
  dependencies:
20
22
  - !ruby/object:Gem::Dependency
21
23
  name: activesupport
@@ -25,12 +27,13 @@ dependencies:
25
27
  requirements:
26
28
  - - "="
27
29
  - !ruby/object:Gem::Version
28
- hash: 3
30
+ hash: 977940594
29
31
  segments:
30
32
  - 3
31
33
  - 1
32
- - 0
33
- version: 3.1.0
34
+ - 1
35
+ - rc1
36
+ version: 3.1.1.rc1
34
37
  type: :runtime
35
38
  version_requirements: *id001
36
39
  - !ruby/object:Gem::Dependency
@@ -41,12 +44,13 @@ dependencies:
41
44
  requirements:
42
45
  - - "="
43
46
  - !ruby/object:Gem::Version
44
- hash: 3
47
+ hash: 977940594
45
48
  segments:
46
49
  - 3
47
50
  - 1
48
- - 0
49
- version: 3.1.0
51
+ - 1
52
+ - rc1
53
+ version: 3.1.1.rc1
50
54
  type: :runtime
51
55
  version_requirements: *id002
52
56
  - !ruby/object:Gem::Dependency
@@ -161,6 +165,7 @@ files:
161
165
  - lib/active_record/connection_adapters/postgresql_adapter.rb
162
166
  - lib/active_record/connection_adapters/sqlite3_adapter.rb
163
167
  - lib/active_record/connection_adapters/sqlite_adapter.rb
168
+ - lib/active_record/connection_adapters/statement_pool.rb
164
169
  - lib/active_record/counter_cache.rb
165
170
  - lib/active_record/dynamic_finder_match.rb
166
171
  - lib/active_record/dynamic_scope_match.rb
@@ -217,6 +222,7 @@ files:
217
222
  - lib/rails/generators/active_record/session_migration/session_migration_generator.rb
218
223
  - lib/rails/generators/active_record/session_migration/templates/migration.rb
219
224
  - lib/rails/generators/active_record.rb
225
+ has_rdoc: true
220
226
  homepage: http://www.rubyonrails.org
221
227
  licenses: []
222
228
 
@@ -240,16 +246,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
240
246
  required_rubygems_version: !ruby/object:Gem::Requirement
241
247
  none: false
242
248
  requirements:
243
- - - ">="
249
+ - - ">"
244
250
  - !ruby/object:Gem::Version
245
- hash: 3
251
+ hash: 25
246
252
  segments:
247
- - 0
248
- version: "0"
253
+ - 1
254
+ - 3
255
+ - 1
256
+ version: 1.3.1
249
257
  requirements: []
250
258
 
251
259
  rubyforge_project:
252
- rubygems_version: 1.8.8
260
+ rubygems_version: 1.3.7
253
261
  signing_key:
254
262
  specification_version: 3
255
263
  summary: Object-relational mapper framework (part of Rails).