activerecord 3.1.4 → 3.1.5.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.

@@ -46,7 +46,7 @@ module ActiveRecord
46
46
  #
47
47
  # def <=>(other_money)
48
48
  # if currency == other_money.currency
49
- # amount <=> amount
49
+ # amount <=> other_money.amount
50
50
  # else
51
51
  # amount <=> other_money.exchange_to(currency).amount
52
52
  # end
@@ -954,23 +954,30 @@ module ActiveRecord #:nodoc:
954
954
  record_id = sti_class.primary_key && record[sti_class.primary_key]
955
955
 
956
956
  if ActiveRecord::IdentityMap.enabled? && record_id
957
+ instance = use_identity_map(sti_class, record_id, record)
958
+ else
959
+ instance = sti_class.allocate.init_with('attributes' => record)
960
+ end
961
+
962
+ instance
963
+ end
964
+
965
+ private
966
+
967
+ def use_identity_map(sti_class, record_id, record)
957
968
  if (column = sti_class.columns_hash[sti_class.primary_key]) && column.number?
958
969
  record_id = record_id.to_i
959
970
  end
971
+
960
972
  if instance = IdentityMap.get(sti_class, record_id)
961
973
  instance.reinit_with('attributes' => record)
962
974
  else
963
975
  instance = sti_class.allocate.init_with('attributes' => record)
964
976
  IdentityMap.add(instance)
965
977
  end
966
- else
967
- instance = sti_class.allocate.init_with('attributes' => record)
968
- end
969
978
 
970
- instance
971
- end
972
-
973
- private
979
+ instance
980
+ end
974
981
 
975
982
  def relation #:nodoc:
976
983
  @relation ||= Relation.new(self, arel_table)
@@ -1054,7 +1061,7 @@ module ActiveRecord #:nodoc:
1054
1061
  super unless all_attributes_exists?(attribute_names)
1055
1062
  if !arguments.first.is_a?(Hash) && arguments.size < attribute_names.size
1056
1063
  ActiveSupport::Deprecation.warn(<<-eowarn)
1057
- Calling dynamic finder with less number of arguments than the number of attributes in method name is deprecated and will raise an ArguementError in the next version of Rails. Please passing `nil' to the argument you want it to be nil.
1064
+ Calling dynamic finder with less number of arguments than the number of attributes in the method name is deprecated and will raise an ArgumentError in the next version of Rails. Please pass `nil' explicitly to the arguments that are left out.
1058
1065
  eowarn
1059
1066
  end
1060
1067
  if match.finder?
@@ -1070,8 +1077,8 @@ Calling dynamic finder with less number of arguments than the number of attribut
1070
1077
  if arguments.size < attribute_names.size
1071
1078
  ActiveSupport::Deprecation.warn(
1072
1079
  "Calling dynamic scope with less number of arguments than the number of attributes in " \
1073
- "method name is deprecated and will raise an ArguementError in the next version of Rails. " \
1074
- "Please passing `nil' to the argument you want it to be nil."
1080
+ "the method name is deprecated and will raise an ArgumentError in the next version of Rails. " \
1081
+ "Please pass `nil' explicitly to the arguments that are left out."
1075
1082
  )
1076
1083
  end
1077
1084
  if match.scope?
@@ -40,6 +40,7 @@ module ActiveRecord
40
40
  define_callbacks :checkout, :checkin
41
41
 
42
42
  attr_accessor :visitor
43
+ attr_reader :logger
43
44
 
44
45
  def initialize(connection, logger = nil) #:nodoc:
45
46
  @active = nil
@@ -543,15 +543,26 @@ module ActiveRecord
543
543
 
544
544
  # Maps logical Rails types to MySQL-specific data types.
545
545
  def type_to_sql(type, limit = nil, precision = nil, scale = nil)
546
- return super unless type.to_s == 'integer'
547
-
548
- case limit
549
- when 1; 'tinyint'
550
- when 2; 'smallint'
551
- when 3; 'mediumint'
552
- when nil, 4, 11; 'int(11)' # compatibility with MySQL default
553
- when 5..8; 'bigint'
554
- else raise(ActiveRecordError, "No integer type has byte size #{limit}")
546
+ case type.to_s
547
+ when 'integer'
548
+ case limit
549
+ when 1; 'tinyint'
550
+ when 2; 'smallint'
551
+ when 3; 'mediumint'
552
+ when nil, 4, 11; 'int(11)' # compatibility with MySQL default
553
+ when 5..8; 'bigint'
554
+ else raise(ActiveRecordError, "No integer type has byte size #{limit}")
555
+ end
556
+ when 'text'
557
+ case limit
558
+ when 0..0xff; 'tinytext'
559
+ when nil, 0x100..0xffff; 'text'
560
+ when 0x10000..0xffffff; 'mediumtext'
561
+ when 0x1000000..0xffffffff; 'longtext'
562
+ else raise(ActiveRecordError, "No text type has character length #{limit}")
563
+ end
564
+ else
565
+ super
555
566
  end
556
567
  end
557
568
 
@@ -738,15 +738,26 @@ module ActiveRecord
738
738
 
739
739
  # Maps logical Rails types to MySQL-specific data types.
740
740
  def type_to_sql(type, limit = nil, precision = nil, scale = nil)
741
- return super unless type.to_s == 'integer'
742
-
743
- case limit
744
- when 1; 'tinyint'
745
- when 2; 'smallint'
746
- when 3; 'mediumint'
747
- when nil, 4, 11; 'int(11)' # compatibility with MySQL default
748
- when 5..8; 'bigint'
749
- else raise(ActiveRecordError, "No integer type has byte size #{limit}")
741
+ case type.to_s
742
+ when 'integer'
743
+ case limit
744
+ when 1; 'tinyint'
745
+ when 2; 'smallint'
746
+ when 3; 'mediumint'
747
+ when nil, 4, 11; 'int(11)' # compatibility with MySQL default
748
+ when 5..8; 'bigint'
749
+ else raise(ActiveRecordError, "No integer type has byte size #{limit}")
750
+ end
751
+ when 'text'
752
+ case limit
753
+ when 0..0xff; 'tinytext'
754
+ when nil, 0x100..0xffff; 'text'
755
+ when 0x10000..0xffffff; 'mediumtext'
756
+ when 0x1000000..0xffffffff; 'longtext'
757
+ else raise(ActiveRecordError, "No text type has character length #{limit}")
758
+ end
759
+ else
760
+ super
750
761
  end
751
762
  end
752
763
 
@@ -215,7 +215,7 @@ module ActiveRecord
215
215
 
216
216
  value = super
217
217
  if column.type == :string && value.encoding == Encoding::ASCII_8BIT
218
- @logger.error "Binary data inserted for `string` type on column `#{column.name}`"
218
+ logger.error "Binary data inserted for `string` type on column `#{column.name}`" if logger
219
219
  value.encode! 'utf-8'
220
220
  end
221
221
  value
@@ -90,7 +90,7 @@ module ActiveRecord
90
90
  end
91
91
 
92
92
  def add(record)
93
- repository[record.class.symbolized_sti_name][record.id] = record
93
+ repository[record.class.symbolized_sti_name][record.id] = record if contain_all_columns?(record)
94
94
  end
95
95
 
96
96
  def remove(record)
@@ -104,6 +104,12 @@ module ActiveRecord
104
104
  def clear
105
105
  repository.clear
106
106
  end
107
+
108
+ private
109
+
110
+ def contain_all_columns?(record)
111
+ (record.class.column_names - record.attribute_names).empty?
112
+ end
107
113
  end
108
114
 
109
115
  # Reinitialize an Identity Map model object from +coder+.
@@ -206,7 +206,7 @@ module ActiveRecord
206
206
  arel.having(*@having_values.uniq.reject{|h| h.blank?}) unless @having_values.empty?
207
207
 
208
208
  arel.take(connection.sanitize_limit(@limit_value)) if @limit_value
209
- arel.skip(@offset_value) if @offset_value
209
+ arel.skip(@offset_value.to_i) if @offset_value
210
210
 
211
211
  arel.group(*@group_values.uniq.reject{|g| g.blank?}) unless @group_values.empty?
212
212
 
@@ -40,7 +40,7 @@ module ActiveRecord
40
40
  def header(stream)
41
41
  define_params = @version ? ":version => #{@version}" : ""
42
42
 
43
- if stream.respond_to?(:external_encoding)
43
+ if stream.respond_to?(:external_encoding) && stream.external_encoding
44
44
  stream.puts "# encoding: #{stream.external_encoding.name}"
45
45
  end
46
46
 
@@ -2,8 +2,8 @@ module ActiveRecord
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
- TINY = 4
6
- PRE = nil
5
+ TINY = 5
6
+ PRE = "rc1"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
9
9
  end
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease:
4
+ hash: 1335462739
5
+ prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
- - 4
10
- version: 3.1.4
9
+ - 5
10
+ - rc
11
+ - 1
12
+ version: 3.1.5.rc1
11
13
  platform: ruby
12
14
  authors:
13
15
  - David Heinemeier Hansson
@@ -15,7 +17,7 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2012-03-01 00:00:00 Z
20
+ date: 2012-05-28 00:00:00 Z
19
21
  dependencies:
20
22
  - !ruby/object:Gem::Dependency
21
23
  name: activesupport
@@ -25,12 +27,14 @@ dependencies:
25
27
  requirements:
26
28
  - - "="
27
29
  - !ruby/object:Gem::Version
28
- hash: 11
30
+ hash: 1335462739
29
31
  segments:
30
32
  - 3
31
33
  - 1
32
- - 4
33
- version: 3.1.4
34
+ - 5
35
+ - rc
36
+ - 1
37
+ version: 3.1.5.rc1
34
38
  type: :runtime
35
39
  version_requirements: *id001
36
40
  - !ruby/object:Gem::Dependency
@@ -41,12 +45,14 @@ dependencies:
41
45
  requirements:
42
46
  - - "="
43
47
  - !ruby/object:Gem::Version
44
- hash: 11
48
+ hash: 1335462739
45
49
  segments:
46
50
  - 3
47
51
  - 1
48
- - 4
49
- version: 3.1.4
52
+ - 5
53
+ - rc
54
+ - 1
55
+ version: 3.1.5.rc1
50
56
  type: :runtime
51
57
  version_requirements: *id002
52
58
  - !ruby/object:Gem::Dependency
@@ -242,16 +248,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
242
248
  required_rubygems_version: !ruby/object:Gem::Requirement
243
249
  none: false
244
250
  requirements:
245
- - - ">="
251
+ - - ">"
246
252
  - !ruby/object:Gem::Version
247
- hash: 3
253
+ hash: 25
248
254
  segments:
249
- - 0
250
- version: "0"
255
+ - 1
256
+ - 3
257
+ - 1
258
+ version: 1.3.1
251
259
  requirements: []
252
260
 
253
261
  rubyforge_project:
254
- rubygems_version: 1.8.16
262
+ rubygems_version: 1.8.22
255
263
  signing_key:
256
264
  specification_version: 3
257
265
  summary: Object-relational mapper framework (part of Rails).