activerecord 3.1.2 → 3.1.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.

@@ -1,3 +1,16 @@
1
+ ## Rails 3.1.3 (unreleased) ##
2
+
3
+ * Perf fix: If we're deleting all records in an association, don't add a IN(..) clause
4
+ to the query. *GH 3672*
5
+
6
+ *Jon Leighton*
7
+
8
+ * Fix bug with referencing other mysql databases in set_table_name. *GH 3690*
9
+
10
+ * Fix performance bug with mysql databases on a server with lots of other databses. *GH 3678*
11
+
12
+ *Christos Zisopoulos and Kenny J*
13
+
1
14
  ## Rails 3.1.2 (unreleased) ##
2
15
 
3
16
  * Fix problem with prepared statements and PostgreSQL when multiple schemas are used.
@@ -89,8 +89,12 @@ module ActiveRecord
89
89
  records.each { |r| r.destroy }
90
90
  update_counter(-records.length) unless inverse_updates_counter_cache?
91
91
  else
92
- keys = records.map { |r| r[reflection.association_primary_key] }
93
- scope = scoped.where(reflection.association_primary_key => keys)
92
+ scope = scoped
93
+
94
+ unless records == load_target
95
+ keys = records.map { |r| r[reflection.association_primary_key] }
96
+ scope = scoped.where(reflection.association_primary_key => keys)
97
+ end
94
98
 
95
99
  if method == :delete_all
96
100
  update_counter(-scope.delete_all)
@@ -573,18 +573,9 @@ module ActiveRecord
573
573
  # Returns a table's primary key and belonging sequence.
574
574
  def pk_and_sequence_for(table)
575
575
  keys = []
576
- sql = <<-SQL
577
- SELECT t.constraint_type, k.column_name
578
- FROM information_schema.table_constraints t
579
- JOIN information_schema.key_column_usage k
580
- USING (constraint_name, table_schema, table_name)
581
- WHERE t.table_schema = DATABASE()
582
- AND t.table_name = '#{table}'
583
- SQL
584
-
585
- result = execute(sql, 'SCHEMA')
576
+ result = execute("SHOW INDEX FROM #{quote_table_name(table)} WHERE Key_name = 'PRIMARY'", 'SCHEMA')
586
577
  result.each(:symbolize_keys => true, :as => :hash) do |row|
587
- keys << row[:column_name] if row[:constraint_type] == "PRIMARY KEY"
578
+ keys << row[:Column_name]
588
579
  end
589
580
  keys.length == 1 ? [keys.first, nil] : nil
590
581
  end
@@ -756,18 +756,9 @@ module ActiveRecord
756
756
  # Returns a table's primary key and belonging sequence.
757
757
  def pk_and_sequence_for(table) #:nodoc:
758
758
  keys = []
759
- sql = <<-SQL
760
- SELECT t.constraint_type, k.column_name
761
- FROM information_schema.table_constraints t
762
- JOIN information_schema.key_column_usage k
763
- USING (constraint_name, table_schema, table_name)
764
- WHERE t.table_schema = DATABASE()
765
- AND t.table_name = '#{table}'
766
- SQL
767
-
768
- result = execute(sql, 'SCHEMA')
759
+ result = execute("SHOW INDEX FROM #{quote_table_name(table)} WHERE Key_name = 'PRIMARY'", 'SCHEMA')
769
760
  result.each_hash do |h|
770
- keys << h["column_name"] if h["constraint_type"] == "PRIMARY KEY"
761
+ keys << h["Column_name"]
771
762
  end
772
763
  result.free
773
764
  keys.length == 1 ? [keys.first, nil] : nil
@@ -2,7 +2,7 @@ module ActiveRecord
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
- TINY = 2
5
+ TINY = 3
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
- - 2
10
- version: 3.1.2
9
+ - 3
10
+ version: 3.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Heinemeier Hansson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-18 00:00:00 Z
18
+ date: 2011-11-20 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activesupport
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - "="
28
28
  - !ruby/object:Gem::Version
29
- hash: 7
29
+ hash: 5
30
30
  segments:
31
31
  - 3
32
32
  - 1
33
- - 2
34
- version: 3.1.2
33
+ - 3
34
+ version: 3.1.3
35
35
  requirement: *id001
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activemodel
@@ -42,12 +42,12 @@ dependencies:
42
42
  requirements:
43
43
  - - "="
44
44
  - !ruby/object:Gem::Version
45
- hash: 7
45
+ hash: 5
46
46
  segments:
47
47
  - 3
48
48
  - 1
49
- - 2
50
- version: 3.1.2
49
+ - 3
50
+ version: 3.1.3
51
51
  requirement: *id002
52
52
  - !ruby/object:Gem::Dependency
53
53
  name: arel