activerecord 3.0.7.rc1 → 3.0.7.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 CHANGED
@@ -1,5 +1,19 @@
1
1
  *Rails 3.0.7 (unreleased)*
2
2
 
3
+ * Destroying records via nested attributes works independent of reject_if LH #6006 [Durran Jordan]
4
+
5
+ * Delegate any? and many? to Model.scoped for consistency [Andrew White]
6
+
7
+ * Quote the ORDER BY clause in batched finds - fixes #6620 [Andrew White]
8
+
9
+ * Change exists? so records are not instantiated - fixes #6127. This prevents after_find
10
+ and after_initialize callbacks being triggered when checking for record existence.
11
+ [Andrew White]
12
+
13
+ * Fix performance bug with attribute accessors which only occurred on Ruby 1.8.7, and ensure we
14
+ cache type-casted values when the column returned from the db contains non-standard chars.
15
+ [Jon Leighton]
16
+
3
17
  * Fix a performance regression introduced here 86acbf1cc050c8fa8c74a10c735e467fb6fd7df8
4
18
  related to read_attribute method [Stian Grytøyr]
5
19
 
@@ -40,11 +40,11 @@ module ActiveRecord
40
40
  if self.serialized_attributes[attr_name]
41
41
  define_read_method_for_serialized_attribute(attr_name)
42
42
  else
43
- define_read_method(attr_name.to_sym, attr_name, columns_hash[attr_name])
43
+ define_read_method(attr_name, attr_name, columns_hash[attr_name])
44
44
  end
45
45
 
46
46
  if attr_name == primary_key && attr_name != "id"
47
- define_read_method(:id, attr_name, columns_hash[attr_name])
47
+ define_read_method('id', attr_name, columns_hash[attr_name])
48
48
  end
49
49
  end
50
50
 
@@ -55,7 +55,9 @@ module ActiveRecord
55
55
  end
56
56
 
57
57
  # Define an attribute reader method. Cope with nil column.
58
- def define_read_method(symbol, attr_name, column)
58
+ # method_name is the same as attr_name except when a non-standard primary key is used,
59
+ # we still define #id as an accessor for the key
60
+ def define_read_method(method_name, attr_name, column)
59
61
  cast_code = column.type_cast_code('v') if column
60
62
  access_code = cast_code ? "(v=@attributes['#{attr_name}']) && #{cast_code}" : "@attributes['#{attr_name}']"
61
63
 
@@ -66,10 +68,26 @@ module ActiveRecord
66
68
  if cache_attribute?(attr_name)
67
69
  access_code = "@attributes_cache['#{attr_name}'] ||= (#{access_code})"
68
70
  end
69
- if symbol =~ /^[a-zA-Z_]\w*[!?=]?$/
70
- generated_attribute_methods.module_eval("def _#{symbol}; #{access_code}; end; alias #{symbol} _#{symbol}", __FILE__, __LINE__)
71
+
72
+ # Where possible, generate the method by evalling a string, as this will result in
73
+ # faster accesses because it avoids the block eval and then string eval incurred
74
+ # by the second branch.
75
+ #
76
+ # The second, slower, branch is necessary to support instances where the database
77
+ # returns columns with extra stuff in (like 'my_column(omg)').
78
+ if method_name =~ /^[a-zA-Z_]\w*[!?=]?$/
79
+ generated_attribute_methods.module_eval <<-STR, __FILE__, __LINE__
80
+ def _#{method_name}
81
+ #{access_code}
82
+ end
83
+
84
+ alias #{method_name} _#{method_name}
85
+ STR
71
86
  else
72
- generated_attribute_methods.send(:define_method, symbol) { eval(access_code) }
87
+ generated_attribute_methods.module_eval do
88
+ define_method("_#{method_name}") { eval(access_code) }
89
+ alias_method(method_name, "_#{method_name}")
90
+ end
73
91
  end
74
92
  end
75
93
  end
@@ -78,7 +96,7 @@ module ActiveRecord
78
96
  # "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)).
79
97
  def read_attribute(attr_name)
80
98
  if respond_to? "_#{attr_name}"
81
- send "_#{attr_name}"
99
+ send "_#{attr_name}" if @attributes.has_key?(attr_name.to_s)
82
100
  else
83
101
  _read_attribute attr_name
84
102
  end
@@ -3,7 +3,7 @@ module ActiveRecord
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
5
  TINY = 7
6
- PRE = "rc1"
6
+ PRE = "rc2"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
9
9
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15424079
4
+ hash: 15424073
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
9
  - 7
10
10
  - rc
11
- - 1
12
- version: 3.0.7.rc1
11
+ - 2
12
+ version: 3.0.7.rc2
13
13
  platform: ruby
14
14
  authors:
15
15
  - David Heinemeier Hansson
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-04-14 00:00:00 -03:00
20
+ date: 2011-04-15 00:00:00 -03:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -28,14 +28,14 @@ dependencies:
28
28
  requirements:
29
29
  - - "="
30
30
  - !ruby/object:Gem::Version
31
- hash: 15424079
31
+ hash: 15424073
32
32
  segments:
33
33
  - 3
34
34
  - 0
35
35
  - 7
36
36
  - rc
37
- - 1
38
- version: 3.0.7.rc1
37
+ - 2
38
+ version: 3.0.7.rc2
39
39
  type: :runtime
40
40
  version_requirements: *id001
41
41
  - !ruby/object:Gem::Dependency
@@ -46,14 +46,14 @@ dependencies:
46
46
  requirements:
47
47
  - - "="
48
48
  - !ruby/object:Gem::Version
49
- hash: 15424079
49
+ hash: 15424073
50
50
  segments:
51
51
  - 3
52
52
  - 0
53
53
  - 7
54
54
  - rc
55
- - 1
56
- version: 3.0.7.rc1
55
+ - 2
56
+ version: 3.0.7.rc2
57
57
  type: :runtime
58
58
  version_requirements: *id002
59
59
  - !ruby/object:Gem::Dependency