activerecord 3.2.1 → 3.2.2.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.

@@ -60,7 +60,7 @@ module ActiveRecord
60
60
  end
61
61
  end
62
62
 
63
- relation.uniq.pluck(column)
63
+ relation.pluck(column)
64
64
  end
65
65
  end
66
66
 
@@ -82,9 +82,8 @@ module ActiveRecord
82
82
  proxy_association.send :add_to_target, r
83
83
  yield(r) if block_given?
84
84
  end
85
- end
86
85
 
87
- if target.respond_to?(method) || (!proxy_association.klass.respond_to?(method) && Class.respond_to?(method))
86
+ elsif target.respond_to?(method) || (!proxy_association.klass.respond_to?(method) && Class.respond_to?(method))
88
87
  if load_target
89
88
  if target.respond_to?(method)
90
89
  target.send(method, *args, &block)
@@ -36,6 +36,28 @@ module ActiveRecord
36
36
  # Generates all the attribute related methods for columns in the database
37
37
  # accessors, mutators and query methods.
38
38
  def define_attribute_methods
39
+ unless defined?(@attribute_methods_mutex)
40
+ msg = "It looks like something (probably a gem/plugin) is overriding the " \
41
+ "ActiveRecord::Base.inherited method. It is important that this hook executes so " \
42
+ "that your models are set up correctly. A workaround has been added to stop this " \
43
+ "causing an error in 3.2, but future versions will simply not work if the hook is " \
44
+ "overridden. If you are using Kaminari, please upgrade as it is known to have had " \
45
+ "this problem.\n\n"
46
+ msg << "The following may help track down the problem:"
47
+
48
+ meth = method(:inherited)
49
+ if meth.respond_to?(:source_location)
50
+ msg << " #{meth.source_location.inspect}"
51
+ else
52
+ msg << " #{meth.inspect}"
53
+ end
54
+ msg << "\n\n"
55
+
56
+ ActiveSupport::Deprecation.warn(msg)
57
+
58
+ @attribute_methods_mutex = Mutex.new
59
+ end
60
+
39
61
  # Use a mutex; we don't want two thread simaltaneously trying to define
40
62
  # attribute methods.
41
63
  @attribute_methods_mutex.synchronize do
@@ -88,6 +88,14 @@ module ActiveRecord
88
88
  super
89
89
  end
90
90
  end
91
+
92
+ def read_attribute_before_type_cast(attr_name)
93
+ if serialized_attributes.include?(attr_name)
94
+ super.unserialized_value
95
+ else
96
+ super
97
+ end
98
+ end
91
99
  end
92
100
  end
93
101
  end
@@ -28,11 +28,14 @@ module ActiveRecord
28
28
  @attributes_cache.delete(attr_name)
29
29
  column = column_for_attribute(attr_name)
30
30
 
31
- if column || @attributes.has_key?(attr_name)
32
- @attributes[attr_name] = type_cast_attribute_for_write(column, value)
33
- else
34
- raise ActiveModel::MissingAttributeError, "can't write unknown attribute `#{attr_name}'"
31
+ unless column || @attributes.has_key?(attr_name)
32
+ ActiveSupport::Deprecation.warn(
33
+ "You're trying to create an attribute `#{attr_name}'. Writing arbitrary " \
34
+ "attributes on a model is deprecated. Please just use `attr_writer` etc."
35
+ )
35
36
  end
37
+
38
+ @attributes[attr_name] = type_cast_attribute_for_write(column, value)
36
39
  end
37
40
  alias_method :raw_write_attribute, :write_attribute
38
41
 
@@ -531,6 +531,8 @@ module ActiveRecord #:nodoc:
531
531
  # The dup method does not preserve the timestamps (created|updated)_(at|on).
532
532
  def initialize_dup(other)
533
533
  cloned_attributes = other.clone_attributes(:read_attribute_before_type_cast)
534
+ self.class.initialize_attributes(cloned_attributes)
535
+
534
536
  cloned_attributes.delete(self.class.primary_key)
535
537
 
536
538
  @attributes = cloned_attributes
@@ -2,9 +2,11 @@ module ActiveRecord
2
2
  module ConnectionAdapters # :nodoc:
3
3
  module DatabaseStatements
4
4
  # Converts an arel AST to SQL
5
- def to_sql(arel)
5
+ def to_sql(arel, binds = [])
6
6
  if arel.respond_to?(:ast)
7
- visitor.accept(arel.ast)
7
+ visitor.accept(arel.ast) do
8
+ quote(*binds.shift.reverse)
9
+ end
8
10
  else
9
11
  arel
10
12
  end
@@ -13,7 +15,7 @@ module ActiveRecord
13
15
  # Returns an array of record hashes with the column names as keys and
14
16
  # column values as values.
15
17
  def select_all(arel, name = nil, binds = [])
16
- select(to_sql(arel), name, binds)
18
+ select(to_sql(arel, binds), name, binds)
17
19
  end
18
20
 
19
21
  # Returns a record hash with the column names as keys and column values
@@ -33,7 +35,7 @@ module ActiveRecord
33
35
  # Returns an array of the values of the first column in a select:
34
36
  # select_values("SELECT id FROM companies LIMIT 3") => [1,2,3]
35
37
  def select_values(arel, name = nil)
36
- result = select_rows(to_sql(arel), name)
38
+ result = select_rows(to_sql(arel, []), name)
37
39
  result.map { |v| v[0] }
38
40
  end
39
41
 
@@ -84,19 +86,19 @@ module ActiveRecord
84
86
  # If the next id was calculated in advance (as in Oracle), it should be
85
87
  # passed in as +id_value+.
86
88
  def insert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, binds = [])
87
- sql, binds = sql_for_insert(to_sql(arel), pk, id_value, sequence_name, binds)
89
+ sql, binds = sql_for_insert(to_sql(arel, binds), pk, id_value, sequence_name, binds)
88
90
  value = exec_insert(sql, name, binds)
89
91
  id_value || last_inserted_id(value)
90
92
  end
91
93
 
92
94
  # Executes the update statement and returns the number of rows affected.
93
95
  def update(arel, name = nil, binds = [])
94
- exec_update(to_sql(arel), name, binds)
96
+ exec_update(to_sql(arel, binds), name, binds)
95
97
  end
96
98
 
97
99
  # Executes the delete statement and returns the number of rows affected.
98
100
  def delete(arel, name = nil, binds = [])
99
- exec_delete(to_sql(arel), name, binds)
101
+ exec_delete(to_sql(arel, binds), name, binds)
100
102
  end
101
103
 
102
104
  # Checks whether there is currently no transaction active. This is done
@@ -57,7 +57,7 @@ module ActiveRecord
57
57
 
58
58
  def select_all(arel, name = nil, binds = [])
59
59
  if @query_cache_enabled
60
- sql = to_sql(arel)
60
+ sql = to_sql(arel, binds)
61
61
  cache_sql(sql, binds) { super(sql, name, binds) }
62
62
  else
63
63
  super
@@ -69,7 +69,7 @@ module ActiveRecord
69
69
  result =
70
70
  if @query_cache[sql].key?(binds)
71
71
  ActiveSupport::Notifications.instrument("sql.active_record",
72
- :sql => sql, :name => "CACHE", :connection_id => object_id)
72
+ :sql => sql, :binds => binds, :name => "CACHE", :connection_id => object_id)
73
73
  @query_cache[sql][binds]
74
74
  else
75
75
  @query_cache[sql][binds] = yield
@@ -426,7 +426,7 @@ module ActiveRecord
426
426
  si_table = Base.table_name_prefix + 'schema_info' + Base.table_name_suffix
427
427
 
428
428
  if table_exists?(si_table)
429
- ActiveRecord::Deprecation.warn "Usage of the schema table `#{si_table}` is deprecated. Please switch to using `schema_migrations` table"
429
+ ActiveSupport::Deprecation.warn "Usage of the schema table `#{si_table}` is deprecated. Please switch to using `schema_migrations` table"
430
430
 
431
431
  old_version = select_value("SELECT version FROM #{quote_table_name(si_table)}").to_i
432
432
  assume_migrated_upto_version(old_version)
@@ -158,7 +158,7 @@ module ActiveRecord
158
158
  # Returns a bind substitution value given a +column+ and list of current
159
159
  # +binds+
160
160
  def substitute_at(column, index)
161
- Arel.sql '?'
161
+ Arel::Nodes::BindParam.new '?'
162
162
  end
163
163
 
164
164
  # REFERENTIAL INTEGRITY ====================================
@@ -1,4 +1,5 @@
1
1
  require 'active_support/core_ext/object/blank'
2
+ require 'arel/visitors/bind_visitor'
2
3
 
3
4
  module ActiveRecord
4
5
  module ConnectionAdapters
@@ -122,12 +123,21 @@ module ActiveRecord
122
123
  :boolean => { :name => "tinyint", :limit => 1 }
123
124
  }
124
125
 
126
+ class BindSubstitution < Arel::Visitors::MySQL # :nodoc:
127
+ include Arel::Visitors::BindVisitor
128
+ end
129
+
125
130
  # FIXME: Make the first parameter more similar for the two adapters
126
131
  def initialize(connection, logger, connection_options, config)
127
132
  super(connection, logger)
128
133
  @connection_options, @config = connection_options, config
129
134
  @quoted_column_names, @quoted_table_names = {}, {}
130
- @visitor = Arel::Visitors::MySQL.new self
135
+
136
+ if config.fetch(:prepared_statements) { true }
137
+ @visitor = Arel::Visitors::MySQL.new self
138
+ else
139
+ @visitor = BindSubstitution.new self
140
+ end
131
141
  end
132
142
 
133
143
  def adapter_name #:nodoc:
@@ -427,7 +437,7 @@ module ActiveRecord
427
437
  table, arguments = args.shift, args
428
438
  method = :"#{command}_sql"
429
439
 
430
- if respond_to?(method)
440
+ if respond_to?(method, true)
431
441
  send(method, table, *arguments)
432
442
  else
433
443
  raise "Unknown method called : #{method}(#{arguments.inspect})"
@@ -505,7 +515,7 @@ module ActiveRecord
505
515
  execute_and_free("SHOW CREATE TABLE #{quote_table_name(table)}", 'SCHEMA') do |result|
506
516
  create_table = each_hash(result).first[:"Create Table"]
507
517
  if create_table.to_s =~ /PRIMARY KEY\s+\((.+)\)/
508
- keys = $1.split(",").map { |key| key.gsub(/`/, "") }
518
+ keys = $1.split(",").map { |key| key.gsub(/[`"]/, "") }
509
519
  keys.length == 1 ? [keys.first, nil] : nil
510
520
  else
511
521
  nil
@@ -541,7 +551,7 @@ module ActiveRecord
541
551
  if options.is_a?(Hash) && length = options[:length]
542
552
  case length
543
553
  when Hash
544
- column_names.each {|name| option_strings[name] += "(#{length[name]})" if length.has_key?(name)}
554
+ column_names.each {|name| option_strings[name] += "(#{length[name]})" if length.has_key?(name) && length[name].present?}
545
555
  when Fixnum
546
556
  column_names.each {|name| option_strings[name] += "(#{length})"}
547
557
  end
@@ -32,6 +32,7 @@ module ActiveRecord
32
32
 
33
33
  def initialize(connection, logger, connection_options, config)
34
34
  super
35
+ @visitor = BindSubstitution.new self
35
36
  configure_connection
36
37
  end
37
38
 
@@ -65,10 +66,6 @@ module ActiveRecord
65
66
  @connection.escape(string)
66
67
  end
67
68
 
68
- def substitute_at(column, index)
69
- Arel.sql "\0"
70
- end
71
-
72
69
  # CONNECTION MANAGEMENT ====================================
73
70
 
74
71
  def active?
@@ -98,7 +95,7 @@ module ActiveRecord
98
95
  # DATABASE STATEMENTS ======================================
99
96
 
100
97
  def explain(arel, binds = [])
101
- sql = "EXPLAIN #{to_sql(arel)}"
98
+ sql = "EXPLAIN #{to_sql(arel, binds.dup)}"
102
99
  start = Time.now
103
100
  result = exec_query(sql, 'EXPLAIN', binds)
104
101
  elapsed = Time.now - start
@@ -224,8 +221,7 @@ module ActiveRecord
224
221
  # Returns an array of record hashes with the column names as keys and
225
222
  # column values as values.
226
223
  def select(sql, name = nil, binds = [])
227
- binds = binds.dup
228
- exec_query(sql.gsub("\0") { quote(*binds.shift.reverse) }, name).to_a
224
+ exec_query(sql, name).to_a
229
225
  end
230
226
 
231
227
  def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
@@ -235,17 +231,11 @@ module ActiveRecord
235
231
  alias :create :insert_sql
236
232
 
237
233
  def exec_insert(sql, name, binds)
238
- binds = binds.dup
239
-
240
- # Pretend to support bind parameters
241
- execute sql.gsub("\0") { quote(*binds.shift.reverse) }, name
234
+ execute to_sql(sql, binds), name
242
235
  end
243
236
 
244
237
  def exec_delete(sql, name, binds)
245
- binds = binds.dup
246
-
247
- # Pretend to support bind parameters
248
- execute sql.gsub("\0") { quote(*binds.shift.reverse) }, name
238
+ execute to_sql(sql, binds), name
249
239
  @connection.affected_rows
250
240
  end
251
241
  alias :exec_update :exec_delete
@@ -1,6 +1,7 @@
1
1
  require 'active_record/connection_adapters/abstract_adapter'
2
2
  require 'active_support/core_ext/object/blank'
3
3
  require 'active_record/connection_adapters/statement_pool'
4
+ require 'arel/visitors/bind_visitor'
4
5
 
5
6
  # Make sure we're using pg high enough for PGResult#values
6
7
  gem 'pg', '~> 0.11'
@@ -303,11 +304,23 @@ module ActiveRecord
303
304
  end
304
305
  end
305
306
 
307
+ class BindSubstitution < Arel::Visitors::PostgreSQL # :nodoc:
308
+ include Arel::Visitors::BindVisitor
309
+ end
310
+
306
311
  # Initializes and connects a PostgreSQL adapter.
307
312
  def initialize(connection, logger, connection_parameters, config)
308
313
  super(connection, logger)
314
+
315
+ if config.fetch(:prepared_statements) { true }
316
+ @visitor = Arel::Visitors::PostgreSQL.new self
317
+ else
318
+ @visitor = BindSubstitution.new self
319
+ end
320
+
321
+ connection_parameters.delete :prepared_statements
322
+
309
323
  @connection_parameters, @config = connection_parameters, config
310
- @visitor = Arel::Visitors::PostgreSQL.new self
311
324
 
312
325
  # @local_tz is initialized as nil to avoid warnings when connect tries to use it
313
326
  @local_tz = nil
@@ -520,7 +533,7 @@ module ActiveRecord
520
533
  # DATABASE STATEMENTS ======================================
521
534
 
522
535
  def explain(arel, binds = [])
523
- sql = "EXPLAIN #{to_sql(arel)}"
536
+ sql = "EXPLAIN #{to_sql(arel, binds)}"
524
537
  ExplainPrettyPrinter.new.pp(exec_query(sql, 'EXPLAIN', binds))
525
538
  end
526
539
 
@@ -642,7 +655,7 @@ module ActiveRecord
642
655
  end
643
656
 
644
657
  def substitute_at(column, index)
645
- Arel.sql("$#{index + 1}")
658
+ Arel::Nodes::BindParam.new "$#{index + 1}"
646
659
  end
647
660
 
648
661
  def exec_query(sql, name = 'SQL', binds = [])
@@ -932,26 +945,46 @@ module ActiveRecord
932
945
  def pk_and_sequence_for(table) #:nodoc:
933
946
  # First try looking for a sequence with a dependency on the
934
947
  # given table's primary key.
935
- result = exec_query(<<-end_sql, 'SCHEMA').rows.first
936
- SELECT attr.attname, ns.nspname, seq.relname
937
- FROM pg_class seq
938
- INNER JOIN pg_depend dep ON seq.oid = dep.objid
939
- INNER JOIN pg_attribute attr ON attr.attrelid = dep.refobjid AND attr.attnum = dep.refobjsubid
940
- INNER JOIN pg_constraint cons ON attr.attrelid = cons.conrelid AND attr.attnum = cons.conkey[1]
941
- INNER JOIN pg_namespace ns ON seq.relnamespace = ns.oid
942
- WHERE seq.relkind = 'S'
943
- AND cons.contype = 'p'
944
- AND dep.refobjid = '#{quote_table_name(table)}'::regclass
948
+ result = query(<<-end_sql, 'PK and serial sequence')[0]
949
+ SELECT attr.attname, seq.relname
950
+ FROM pg_class seq,
951
+ pg_attribute attr,
952
+ pg_depend dep,
953
+ pg_namespace name,
954
+ pg_constraint cons
955
+ WHERE seq.oid = dep.objid
956
+ AND seq.relkind = 'S'
957
+ AND attr.attrelid = dep.refobjid
958
+ AND attr.attnum = dep.refobjsubid
959
+ AND attr.attrelid = cons.conrelid
960
+ AND attr.attnum = cons.conkey[1]
961
+ AND cons.contype = 'p'
962
+ AND dep.refobjid = '#{quote_table_name(table)}'::regclass
945
963
  end_sql
946
964
 
947
- # [primary_key, sequence]
948
- if result.second == 'public' then
949
- sequence = result.last
950
- else
951
- sequence = result.second+'.'+result.last
965
+ if result.nil? or result.empty?
966
+ # If that fails, try parsing the primary key's default value.
967
+ # Support the 7.x and 8.0 nextval('foo'::text) as well as
968
+ # the 8.1+ nextval('foo'::regclass).
969
+ result = query(<<-end_sql, 'PK and custom sequence')[0]
970
+ SELECT attr.attname,
971
+ CASE
972
+ WHEN split_part(def.adsrc, '''', 2) ~ '.' THEN
973
+ substr(split_part(def.adsrc, '''', 2),
974
+ strpos(split_part(def.adsrc, '''', 2), '.')+1)
975
+ ELSE split_part(def.adsrc, '''', 2)
976
+ END
977
+ FROM pg_class t
978
+ JOIN pg_attribute attr ON (t.oid = attrelid)
979
+ JOIN pg_attrdef def ON (adrelid = attrelid AND adnum = attnum)
980
+ JOIN pg_constraint cons ON (conrelid = adrelid AND adnum = conkey[1])
981
+ WHERE t.oid = '#{quote_table_name(table)}'::regclass
982
+ AND cons.contype = 'p'
983
+ AND def.adsrc ~* 'nextval'
984
+ end_sql
952
985
  end
953
986
 
954
- [result.first, sequence]
987
+ [result.first, result.last]
955
988
  rescue
956
989
  nil
957
990
  end
@@ -1,31 +1,17 @@
1
1
  require 'active_record/connection_adapters/abstract_adapter'
2
2
  require 'active_record/connection_adapters/statement_pool'
3
3
  require 'active_support/core_ext/string/encoding'
4
+ require 'arel/visitors/bind_visitor'
4
5
 
5
6
  module ActiveRecord
6
7
  module ConnectionAdapters #:nodoc:
7
8
  class SQLiteColumn < Column #:nodoc:
8
9
  class << self
9
- def string_to_binary(value)
10
- value.gsub(/\0|\%/n) do |b|
11
- case b
12
- when "\0" then "%00"
13
- when "%" then "%25"
14
- end
15
- end
16
- end
17
-
18
10
  def binary_to_string(value)
19
11
  if value.respond_to?(:force_encoding) && value.encoding != Encoding::ASCII_8BIT
20
12
  value = value.force_encoding(Encoding::ASCII_8BIT)
21
13
  end
22
-
23
- value.gsub(/%00|%25/n) do |b|
24
- case b
25
- when "%00" then "\0"
26
- when "%25" then "%"
27
- end
28
- end
14
+ value
29
15
  end
30
16
  end
31
17
  end
@@ -84,12 +70,21 @@ module ActiveRecord
84
70
  end
85
71
  end
86
72
 
73
+ class BindSubstitution < Arel::Visitors::SQLite # :nodoc:
74
+ include Arel::Visitors::BindVisitor
75
+ end
76
+
87
77
  def initialize(connection, logger, config)
88
78
  super(connection, logger)
89
79
  @statements = StatementPool.new(@connection,
90
80
  config.fetch(:statement_limit) { 1000 })
91
81
  @config = config
92
- @visitor = Arel::Visitors::SQLite.new self
82
+
83
+ if config.fetch(:prepared_statements) { true }
84
+ @visitor = Arel::Visitors::SQLite.new self
85
+ else
86
+ @visitor = BindSubstitution.new self
87
+ end
93
88
  end
94
89
 
95
90
  def adapter_name #:nodoc:
@@ -225,7 +220,7 @@ module ActiveRecord
225
220
  # DATABASE STATEMENTS ======================================
226
221
 
227
222
  def explain(arel, binds = [])
228
- sql = "EXPLAIN QUERY PLAN #{to_sql(arel)}"
223
+ sql = "EXPLAIN QUERY PLAN #{to_sql(arel, binds)}"
229
224
  ExplainPrettyPrinter.new.pp(exec_query(sql, 'EXPLAIN', binds))
230
225
  end
231
226
 
@@ -19,7 +19,7 @@ module ActiveRecord
19
19
  counters.each do |association|
20
20
  has_many_association = reflect_on_association(association.to_sym)
21
21
 
22
- expected_name = if has_many_association.options[:as]
22
+ if has_many_association.options[:as]
23
23
  has_many_association.options[:as].to_s.classify
24
24
  else
25
25
  self.name
@@ -25,7 +25,7 @@ module ActiveRecord
25
25
  if match = (DynamicFinderMatch.match(method_id) || DynamicScopeMatch.match(method_id))
26
26
  attribute_names = match.attribute_names
27
27
  super unless all_attributes_exists?(attribute_names)
28
- if arguments.size < attribute_names.size
28
+ if !(match.is_a?(DynamicFinderMatch) && match.instantiator? && arguments.first.is_a?(Hash)) && arguments.size < attribute_names.size
29
29
  method_trace = "#{__FILE__}:#{__LINE__}:in `#{method_id}'"
30
30
  backtrace = [method_trace] + caller
31
31
  raise ArgumentError, "wrong number of arguments (#{arguments.size} for #{attribute_names.size})", backtrace
@@ -11,7 +11,10 @@ module ActiveRecord
11
11
 
12
12
  # SCHEMA queries cannot be EXPLAINed, also we do not want to run EXPLAIN on
13
13
  # our own EXPLAINs now matter how loopingly beautiful that would be.
14
- IGNORED_PAYLOADS = %w(SCHEMA EXPLAIN)
14
+ #
15
+ # On the other hand, we want to monitor the performance of our real database
16
+ # queries, not the performance of the access to the query cache.
17
+ IGNORED_PAYLOADS = %w(SCHEMA EXPLAIN CACHE)
15
18
  def ignore_payload?(payload)
16
19
  payload[:exception] || IGNORED_PAYLOADS.include?(payload[:name])
17
20
  end
@@ -163,6 +163,9 @@ db_namespace = namespace :db do
163
163
  else
164
164
  raise "unknown schema format #{ActiveRecord::Base.schema_format}"
165
165
  end
166
+ # Allow this task to be called as many times as required. An example is the
167
+ # migrate:redo task, which calls other two internally that depend on this one.
168
+ db_namespace['_dump'].reenable
166
169
  end
167
170
 
168
171
  namespace :migrate do
@@ -613,7 +616,7 @@ def firebird_db_string(config)
613
616
  end
614
617
 
615
618
  def set_psql_env(config)
616
- ENV['PGHOST'] = config['host'] if config['host']
619
+ ENV['PGHOST'] = config['host'] if config['host']
617
620
  ENV['PGPORT'] = config['port'].to_s if config['port']
618
621
  ENV['PGPASSWORD'] = config['password'].to_s if config['password']
619
622
  ENV['PGUSER'] = config['username'].to_s if config['username']
@@ -77,6 +77,7 @@ module ActiveRecord
77
77
  end
78
78
 
79
79
  def initialize_copy(other)
80
+ @bind_values = @bind_values.dup
80
81
  reset
81
82
  end
82
83
 
@@ -453,7 +454,7 @@ module ActiveRecord
453
454
  end
454
455
 
455
456
  def to_sql
456
- @to_sql ||= klass.connection.to_sql(arel)
457
+ @to_sql ||= klass.connection.to_sql(arel, @bind_values.dup)
457
458
  end
458
459
 
459
460
  def where_values_hash
@@ -208,7 +208,7 @@ module ActiveRecord
208
208
  def find_with_associations
209
209
  join_dependency = construct_join_dependency_for_association_find
210
210
  relation = construct_relation_for_association_find(join_dependency)
211
- rows = connection.select_all(relation, 'SQL', relation.bind_values)
211
+ rows = connection.select_all(relation, 'SQL', relation.bind_values.dup)
212
212
  join_dependency.instantiate(rows)
213
213
  rescue ThrowResult
214
214
  []
@@ -163,8 +163,9 @@ module ActiveRecord #:nodoc:
163
163
  #
164
164
  # class IHaveMyOwnXML < ActiveRecord::Base
165
165
  # def to_xml(options = {})
166
+ # require 'builder'
166
167
  # options[:indent] ||= 2
167
- # xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
168
+ # xml = options[:builder] ||= ::Builder::XmlMarkup.new(:indent => options[:indent])
168
169
  # xml.instruct! unless options[:skip_instruct]
169
170
  # xml.level_one do
170
171
  # xml.tag!(:second_level, 'content')
@@ -2,8 +2,8 @@ module ActiveRecord
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 2
5
- TINY = 1
6
- PRE = nil
5
+ TINY = 2
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: 13
5
- prerelease:
4
+ hash: 15424071
5
+ prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 2
9
+ - 2
10
+ - rc
9
11
  - 1
10
- version: 3.2.1
12
+ version: 3.2.2.rc1
11
13
  platform: ruby
12
14
  authors:
13
15
  - David Heinemeier Hansson
@@ -15,8 +17,7 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2012-01-26 00:00:00 -08:00
19
- default_executable:
20
+ date: 2012-02-22 00:00:00 Z
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
23
  name: activesupport
@@ -26,12 +27,14 @@ dependencies:
26
27
  requirements:
27
28
  - - "="
28
29
  - !ruby/object:Gem::Version
29
- hash: 13
30
+ hash: 15424071
30
31
  segments:
31
32
  - 3
32
33
  - 2
34
+ - 2
35
+ - rc
33
36
  - 1
34
- version: 3.2.1
37
+ version: 3.2.2.rc1
35
38
  type: :runtime
36
39
  version_requirements: *id001
37
40
  - !ruby/object:Gem::Dependency
@@ -42,12 +45,14 @@ dependencies:
42
45
  requirements:
43
46
  - - "="
44
47
  - !ruby/object:Gem::Version
45
- hash: 13
48
+ hash: 15424071
46
49
  segments:
47
50
  - 3
48
51
  - 2
52
+ - 2
53
+ - rc
49
54
  - 1
50
- version: 3.2.1
55
+ version: 3.2.2.rc1
51
56
  type: :runtime
52
57
  version_requirements: *id002
53
58
  - !ruby/object:Gem::Dependency
@@ -58,12 +63,12 @@ dependencies:
58
63
  requirements:
59
64
  - - ~>
60
65
  - !ruby/object:Gem::Version
61
- hash: 7
66
+ hash: 3
62
67
  segments:
63
68
  - 3
64
69
  - 0
65
- - 0
66
- version: 3.0.0
70
+ - 2
71
+ version: 3.0.2
67
72
  type: :runtime
68
73
  version_requirements: *id003
69
74
  - !ruby/object:Gem::Dependency
@@ -95,152 +100,151 @@ files:
95
100
  - MIT-LICENSE
96
101
  - README.rdoc
97
102
  - examples/associations.png
98
- - examples/simple.rb
99
103
  - examples/performance.rb
100
- - lib/active_record.rb
101
- - lib/active_record/nested_attributes.rb
102
- - lib/active_record/locale/en.yml
103
- - lib/active_record/model_schema.rb
104
- - lib/active_record/relation/delegation.rb
105
- - lib/active_record/relation/spawn_methods.rb
106
- - lib/active_record/relation/query_methods.rb
107
- - lib/active_record/relation/finder_methods.rb
108
- - lib/active_record/relation/batches.rb
109
- - lib/active_record/relation/calculations.rb
110
- - lib/active_record/relation/predicate_builder.rb
111
- - lib/active_record/railtie.rb
112
- - lib/active_record/autosave_association.rb
113
- - lib/active_record/result.rb
104
+ - examples/simple.rb
114
105
  - lib/active_record/aggregations.rb
115
- - lib/active_record/railties/jdbcmysql_error.rb
116
- - lib/active_record/railties/console_sandbox.rb
117
- - lib/active_record/railties/databases.rake
118
- - lib/active_record/railties/controller_runtime.rb
119
- - lib/active_record/explain_subscriber.rb
120
- - lib/active_record/connection_adapters/mysql_adapter.rb
121
- - lib/active_record/connection_adapters/mysql2_adapter.rb
122
- - lib/active_record/connection_adapters/abstract/connection_pool.rb
123
- - lib/active_record/connection_adapters/abstract/database_statements.rb
124
- - lib/active_record/connection_adapters/abstract/connection_specification.rb
125
- - lib/active_record/connection_adapters/abstract/quoting.rb
126
- - lib/active_record/connection_adapters/abstract/schema_definitions.rb
127
- - lib/active_record/connection_adapters/abstract/schema_statements.rb
128
- - lib/active_record/connection_adapters/abstract/database_limits.rb
129
- - lib/active_record/connection_adapters/abstract/query_cache.rb
130
- - lib/active_record/connection_adapters/abstract_adapter.rb
131
- - lib/active_record/connection_adapters/column.rb
132
- - lib/active_record/connection_adapters/abstract_mysql_adapter.rb
133
- - lib/active_record/connection_adapters/sqlite_adapter.rb
134
- - lib/active_record/connection_adapters/postgresql_adapter.rb
135
- - lib/active_record/connection_adapters/statement_pool.rb
136
- - lib/active_record/connection_adapters/schema_cache.rb
137
- - lib/active_record/connection_adapters/sqlite3_adapter.rb
138
- - lib/active_record/scoping/named.rb
139
- - lib/active_record/scoping/default.rb
140
- - lib/active_record/reflection.rb
141
- - lib/active_record/test_case.rb
142
- - lib/active_record/translation.rb
143
- - lib/active_record/associations.rb
144
- - lib/active_record/session_store.rb
145
- - lib/active_record/dynamic_scope_match.rb
146
- - lib/active_record/dynamic_finder_match.rb
147
- - lib/active_record/scoping.rb
148
- - lib/active_record/attribute_assignment.rb
149
- - lib/active_record/querying.rb
150
- - lib/active_record/attribute_methods/before_type_cast.rb
151
- - lib/active_record/attribute_methods/read.rb
152
- - lib/active_record/attribute_methods/primary_key.rb
153
- - lib/active_record/attribute_methods/query.rb
154
- - lib/active_record/attribute_methods/write.rb
155
- - lib/active_record/attribute_methods/time_zone_conversion.rb
156
- - lib/active_record/attribute_methods/dirty.rb
157
- - lib/active_record/attribute_methods/deprecated_underscore_read.rb
158
- - lib/active_record/attribute_methods/serialization.rb
159
- - lib/active_record/sanitization.rb
160
- - lib/active_record/associations/has_many_through_association.rb
106
+ - lib/active_record/associations/alias_tracker.rb
107
+ - lib/active_record/associations/association.rb
108
+ - lib/active_record/associations/association_scope.rb
109
+ - lib/active_record/associations/belongs_to_association.rb
110
+ - lib/active_record/associations/belongs_to_polymorphic_association.rb
161
111
  - lib/active_record/associations/builder/association.rb
112
+ - lib/active_record/associations/builder/belongs_to.rb
162
113
  - lib/active_record/associations/builder/collection_association.rb
163
- - lib/active_record/associations/builder/has_one.rb
164
114
  - lib/active_record/associations/builder/has_and_belongs_to_many.rb
165
- - lib/active_record/associations/builder/belongs_to.rb
166
- - lib/active_record/associations/builder/singular_association.rb
167
115
  - lib/active_record/associations/builder/has_many.rb
168
- - lib/active_record/associations/alias_tracker.rb
169
- - lib/active_record/associations/association.rb
116
+ - lib/active_record/associations/builder/has_one.rb
117
+ - lib/active_record/associations/builder/singular_association.rb
170
118
  - lib/active_record/associations/collection_association.rb
171
- - lib/active_record/associations/join_helper.rb
172
- - lib/active_record/associations/join_dependency/join_part.rb
119
+ - lib/active_record/associations/collection_proxy.rb
120
+ - lib/active_record/associations/has_and_belongs_to_many_association.rb
121
+ - lib/active_record/associations/has_many_association.rb
122
+ - lib/active_record/associations/has_many_through_association.rb
123
+ - lib/active_record/associations/has_one_association.rb
124
+ - lib/active_record/associations/has_one_through_association.rb
173
125
  - lib/active_record/associations/join_dependency/join_association.rb
174
126
  - lib/active_record/associations/join_dependency/join_base.rb
175
- - lib/active_record/associations/singular_association.rb
176
- - lib/active_record/associations/has_one_association.rb
177
- - lib/active_record/associations/belongs_to_association.rb
178
- - lib/active_record/associations/association_scope.rb
179
- - lib/active_record/associations/has_many_association.rb
127
+ - lib/active_record/associations/join_dependency/join_part.rb
128
+ - lib/active_record/associations/join_dependency.rb
129
+ - lib/active_record/associations/join_helper.rb
180
130
  - lib/active_record/associations/preloader/association.rb
131
+ - lib/active_record/associations/preloader/belongs_to.rb
181
132
  - lib/active_record/associations/preloader/collection_association.rb
182
- - lib/active_record/associations/preloader/has_one.rb
183
133
  - lib/active_record/associations/preloader/has_and_belongs_to_many.rb
184
- - lib/active_record/associations/preloader/belongs_to.rb
185
- - lib/active_record/associations/preloader/singular_association.rb
186
- - lib/active_record/associations/preloader/has_one_through.rb
134
+ - lib/active_record/associations/preloader/has_many.rb
187
135
  - lib/active_record/associations/preloader/has_many_through.rb
136
+ - lib/active_record/associations/preloader/has_one.rb
137
+ - lib/active_record/associations/preloader/has_one_through.rb
138
+ - lib/active_record/associations/preloader/singular_association.rb
188
139
  - lib/active_record/associations/preloader/through_association.rb
189
- - lib/active_record/associations/preloader/has_many.rb
190
- - lib/active_record/associations/has_one_through_association.rb
191
- - lib/active_record/associations/through_association.rb
192
- - lib/active_record/associations/join_dependency.rb
193
- - lib/active_record/associations/collection_proxy.rb
194
- - lib/active_record/associations/belongs_to_polymorphic_association.rb
195
- - lib/active_record/associations/has_and_belongs_to_many_association.rb
196
140
  - lib/active_record/associations/preloader.rb
197
- - lib/active_record/persistence.rb
198
- - lib/active_record/locking/optimistic.rb
199
- - lib/active_record/locking/pessimistic.rb
200
- - lib/active_record/schema.rb
201
- - lib/active_record/relation.rb
141
+ - lib/active_record/associations/singular_association.rb
142
+ - lib/active_record/associations/through_association.rb
143
+ - lib/active_record/associations.rb
144
+ - lib/active_record/attribute_assignment.rb
145
+ - lib/active_record/attribute_methods/before_type_cast.rb
146
+ - lib/active_record/attribute_methods/deprecated_underscore_read.rb
147
+ - lib/active_record/attribute_methods/dirty.rb
148
+ - lib/active_record/attribute_methods/primary_key.rb
149
+ - lib/active_record/attribute_methods/query.rb
150
+ - lib/active_record/attribute_methods/read.rb
151
+ - lib/active_record/attribute_methods/serialization.rb
152
+ - lib/active_record/attribute_methods/time_zone_conversion.rb
153
+ - lib/active_record/attribute_methods/write.rb
154
+ - lib/active_record/attribute_methods.rb
155
+ - lib/active_record/autosave_association.rb
202
156
  - lib/active_record/base.rb
203
- - lib/active_record/identity_map.rb
204
- - lib/active_record/inheritance.rb
205
- - lib/active_record/errors.rb
206
- - lib/active_record/explain.rb
207
- - lib/active_record/coders/yaml_column.rb
208
- - lib/active_record/integration.rb
209
157
  - lib/active_record/callbacks.rb
158
+ - lib/active_record/coders/yaml_column.rb
159
+ - lib/active_record/connection_adapters/abstract/connection_pool.rb
160
+ - lib/active_record/connection_adapters/abstract/connection_specification.rb
161
+ - lib/active_record/connection_adapters/abstract/database_limits.rb
162
+ - lib/active_record/connection_adapters/abstract/database_statements.rb
163
+ - lib/active_record/connection_adapters/abstract/query_cache.rb
164
+ - lib/active_record/connection_adapters/abstract/quoting.rb
165
+ - lib/active_record/connection_adapters/abstract/schema_definitions.rb
166
+ - lib/active_record/connection_adapters/abstract/schema_statements.rb
167
+ - lib/active_record/connection_adapters/abstract_adapter.rb
168
+ - lib/active_record/connection_adapters/abstract_mysql_adapter.rb
169
+ - lib/active_record/connection_adapters/column.rb
170
+ - lib/active_record/connection_adapters/mysql2_adapter.rb
171
+ - lib/active_record/connection_adapters/mysql_adapter.rb
172
+ - lib/active_record/connection_adapters/postgresql_adapter.rb
173
+ - lib/active_record/connection_adapters/schema_cache.rb
174
+ - lib/active_record/connection_adapters/sqlite3_adapter.rb
175
+ - lib/active_record/connection_adapters/sqlite_adapter.rb
176
+ - lib/active_record/connection_adapters/statement_pool.rb
210
177
  - lib/active_record/counter_cache.rb
211
- - lib/active_record/validations.rb
212
- - lib/active_record/version.rb
213
- - lib/active_record/timestamp.rb
214
- - lib/active_record/observer.rb
215
- - lib/active_record/serializers/xml_serializer.rb
216
- - lib/active_record/fixtures.rb
217
- - lib/active_record/validations/associated.rb
218
- - lib/active_record/validations/uniqueness.rb
178
+ - lib/active_record/dynamic_finder_match.rb
179
+ - lib/active_record/dynamic_matchers.rb
180
+ - lib/active_record/dynamic_scope_match.rb
181
+ - lib/active_record/errors.rb
182
+ - lib/active_record/explain.rb
183
+ - lib/active_record/explain_subscriber.rb
219
184
  - lib/active_record/fixtures/file.rb
185
+ - lib/active_record/fixtures.rb
186
+ - lib/active_record/identity_map.rb
187
+ - lib/active_record/inheritance.rb
188
+ - lib/active_record/integration.rb
189
+ - lib/active_record/locale/en.yml
190
+ - lib/active_record/locking/optimistic.rb
191
+ - lib/active_record/locking/pessimistic.rb
220
192
  - lib/active_record/log_subscriber.rb
221
193
  - lib/active_record/migration/command_recorder.rb
222
- - lib/active_record/dynamic_matchers.rb
223
- - lib/active_record/schema_dumper.rb
224
- - lib/active_record/query_cache.rb
225
- - lib/active_record/attribute_methods.rb
226
194
  - lib/active_record/migration.rb
227
- - lib/active_record/store.rb
228
- - lib/active_record/transactions.rb
195
+ - lib/active_record/model_schema.rb
196
+ - lib/active_record/nested_attributes.rb
197
+ - lib/active_record/observer.rb
198
+ - lib/active_record/persistence.rb
199
+ - lib/active_record/query_cache.rb
200
+ - lib/active_record/querying.rb
201
+ - lib/active_record/railtie.rb
202
+ - lib/active_record/railties/console_sandbox.rb
203
+ - lib/active_record/railties/controller_runtime.rb
204
+ - lib/active_record/railties/databases.rake
205
+ - lib/active_record/railties/jdbcmysql_error.rb
229
206
  - lib/active_record/readonly_attributes.rb
207
+ - lib/active_record/reflection.rb
208
+ - lib/active_record/relation/batches.rb
209
+ - lib/active_record/relation/calculations.rb
210
+ - lib/active_record/relation/delegation.rb
211
+ - lib/active_record/relation/finder_methods.rb
212
+ - lib/active_record/relation/predicate_builder.rb
213
+ - lib/active_record/relation/query_methods.rb
214
+ - lib/active_record/relation/spawn_methods.rb
215
+ - lib/active_record/relation.rb
216
+ - lib/active_record/result.rb
217
+ - lib/active_record/sanitization.rb
218
+ - lib/active_record/schema.rb
219
+ - lib/active_record/schema_dumper.rb
220
+ - lib/active_record/scoping/default.rb
221
+ - lib/active_record/scoping/named.rb
222
+ - lib/active_record/scoping.rb
230
223
  - lib/active_record/serialization.rb
231
- - lib/rails/generators/active_record.rb
232
- - lib/rails/generators/active_record/observer/observer_generator.rb
233
- - lib/rails/generators/active_record/observer/templates/observer.rb
224
+ - lib/active_record/serializers/xml_serializer.rb
225
+ - lib/active_record/session_store.rb
226
+ - lib/active_record/store.rb
227
+ - lib/active_record/test_case.rb
228
+ - lib/active_record/timestamp.rb
229
+ - lib/active_record/transactions.rb
230
+ - lib/active_record/translation.rb
231
+ - lib/active_record/validations/associated.rb
232
+ - lib/active_record/validations/uniqueness.rb
233
+ - lib/active_record/validations.rb
234
+ - lib/active_record/version.rb
235
+ - lib/active_record.rb
236
+ - lib/rails/generators/active_record/migration/migration_generator.rb
237
+ - lib/rails/generators/active_record/migration/templates/migration.rb
238
+ - lib/rails/generators/active_record/migration.rb
234
239
  - lib/rails/generators/active_record/model/model_generator.rb
240
+ - lib/rails/generators/active_record/model/templates/migration.rb
235
241
  - lib/rails/generators/active_record/model/templates/model.rb
236
242
  - lib/rails/generators/active_record/model/templates/module.rb
237
- - lib/rails/generators/active_record/model/templates/migration.rb
243
+ - lib/rails/generators/active_record/observer/observer_generator.rb
244
+ - lib/rails/generators/active_record/observer/templates/observer.rb
238
245
  - lib/rails/generators/active_record/session_migration/session_migration_generator.rb
239
246
  - lib/rails/generators/active_record/session_migration/templates/migration.rb
240
- - lib/rails/generators/active_record/migration/migration_generator.rb
241
- - lib/rails/generators/active_record/migration/templates/migration.rb
242
- - lib/rails/generators/active_record/migration.rb
243
- has_rdoc: true
247
+ - lib/rails/generators/active_record.rb
244
248
  homepage: http://www.rubyonrails.org
245
249
  licenses: []
246
250
 
@@ -264,16 +268,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
264
268
  required_rubygems_version: !ruby/object:Gem::Requirement
265
269
  none: false
266
270
  requirements:
267
- - - ">="
271
+ - - ">"
268
272
  - !ruby/object:Gem::Version
269
- hash: 3
273
+ hash: 25
270
274
  segments:
271
- - 0
272
- version: "0"
275
+ - 1
276
+ - 3
277
+ - 1
278
+ version: 1.3.1
273
279
  requirements: []
274
280
 
275
281
  rubyforge_project:
276
- rubygems_version: 1.6.2
282
+ rubygems_version: 1.8.16
277
283
  signing_key:
278
284
  specification_version: 3
279
285
  summary: Object-relational mapper framework (part of Rails).