public
Fork of rails/rails
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/samgranieri/rails.git
Extract owner_quoted_id so it can be overridden.  [#292 state:committed]
indirect (author)
Wed Jun 04 13:58:58 -0700 2008
jeremy (committer)
Wed Jun 25 19:04:09 -0700 2008
commit  0b12da44aa35b643b17ab1b61634ff952993e357
tree    6774141167461cc920922b532274866726eb67aa
parent  a93ea88c0623b4f65af98c0eb55924c335bb3ac1
...
219
220
221
 
 
 
 
222
223
224
...
219
220
221
222
223
224
225
226
227
228
0
@@ -219,6 +219,10 @@ module ActiveRecord
0
         def flatten_deeper(array)
0
           array.collect { |element| element.respond_to?(:flatten) ? element.flatten : element }.flatten
0
         end
0
+
0
+ def owner_quoted_id
0
+ @owner.quoted_id
0
+ end
0
     end
0
   end
0
 end
...
37
38
39
40
 
41
42
43
...
64
65
66
67
 
68
69
70
...
75
76
77
78
 
79
80
81
...
37
38
39
 
40
41
42
43
...
64
65
66
 
67
68
69
70
...
75
76
77
 
78
79
80
81
0
@@ -37,7 +37,7 @@ module ActiveRecord
0
             attributes = columns.inject({}) do |attrs, column|
0
               case column.name.to_s
0
                 when @reflection.primary_key_name.to_s
0
- attrs[column.name] = @owner.quoted_id
0
+ attrs[column.name] = owner_quoted_id
0
                 when @reflection.association_foreign_key.to_s
0
                   attrs[column.name] = record.quoted_id
0
                 else
0
@@ -64,7 +64,7 @@ module ActiveRecord
0
             records.each { |record| @owner.connection.delete(interpolate_sql(sql, record)) }
0
           else
0
             ids = quoted_record_ids(records)
0
- sql = "DELETE FROM #{@owner.connection.quote_table_name @reflection.options[:join_table]} WHERE #{@reflection.primary_key_name} = #{@owner.quoted_id} AND #{@reflection.association_foreign_key} IN (#{ids})"
0
+ sql = "DELETE FROM #{@owner.connection.quote_table_name @reflection.options[:join_table]} WHERE #{@reflection.primary_key_name} = #{owner_quoted_id} AND #{@reflection.association_foreign_key} IN (#{ids})"
0
             @owner.connection.delete(sql)
0
           end
0
         end
0
@@ -75,7 +75,7 @@ module ActiveRecord
0
           if @reflection.options[:finder_sql]
0
             @finder_sql = @reflection.options[:finder_sql]
0
           else
0
- @finder_sql = "#{@owner.connection.quote_table_name @reflection.options[:join_table]}.#{@reflection.primary_key_name} = #{@owner.quoted_id} "
0
+ @finder_sql = "#{@owner.connection.quote_table_name @reflection.options[:join_table]}.#{@reflection.primary_key_name} = #{owner_quoted_id} "
0
             @finder_sql << " AND (#{conditions})" if conditions
0
           end
0
 
...
60
61
62
63
 
64
65
66
...
76
77
78
79
 
80
81
82
83
84
 
85
86
87
...
60
61
62
 
63
64
65
66
...
76
77
78
 
79
80
81
82
83
 
84
85
86
87
0
@@ -60,7 +60,7 @@ module ActiveRecord
0
               ids = quoted_record_ids(records)
0
               @reflection.klass.update_all(
0
                 "#{@reflection.primary_key_name} = NULL",
0
- "#{@reflection.primary_key_name} = #{@owner.quoted_id} AND #{@reflection.klass.primary_key} IN (#{ids})"
0
+ "#{@reflection.primary_key_name} = #{owner_quoted_id} AND #{@reflection.klass.primary_key} IN (#{ids})"
0
               )
0
           end
0
         end
0
@@ -76,12 +76,12 @@ module ActiveRecord
0
 
0
             when @reflection.options[:as]
0
               @finder_sql =
0
- "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{@owner.quoted_id} AND " +
0
+ "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{owner_quoted_id} AND " +
0
                 "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.base_class.name.to_s)}"
0
               @finder_sql << " AND (#{conditions})" if conditions
0
             
0
             else
0
- @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{@owner.quoted_id}"
0
+ @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{owner_quoted_id}"
0
               @finder_sql << " AND (#{conditions})" if conditions
0
           end
0
 
...
107
108
109
110
 
111
112
113
114
115
 
116
117
118
...
183
184
185
186
 
187
188
189
...
107
108
109
 
110
111
112
113
114
 
115
116
117
118
...
183
184
185
 
186
187
188
189
0
@@ -107,12 +107,12 @@ module ActiveRecord
0
         # Associate attributes pointing to owner, quoted.
0
         def construct_quoted_owner_attributes(reflection)
0
           if as = reflection.options[:as]
0
- { "#{as}_id" => @owner.quoted_id,
0
+ { "#{as}_id" => owner_quoted_id,
0
               "#{as}_type" => reflection.klass.quote_value(
0
                 @owner.class.base_class.name.to_s,
0
                 reflection.klass.columns_hash["#{as}_type"]) }
0
           else
0
- { reflection.primary_key_name => @owner.quoted_id }
0
+ { reflection.primary_key_name => owner_quoted_id }
0
           end
0
         end
0
 
0
@@ -183,7 +183,7 @@ module ActiveRecord
0
             when @reflection.options[:finder_sql]
0
               @finder_sql = interpolate_sql(@reflection.options[:finder_sql])
0
 
0
- @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{@owner.quoted_id}"
0
+ @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{owner_quoted_id}"
0
               @finder_sql << " AND (#{conditions})" if conditions
0
             else
0
               @finder_sql = construct_conditions
...
63
64
65
66
 
67
68
69
 
70
71
72
...
63
64
65
 
66
67
68
 
69
70
71
72
0
@@ -63,10 +63,10 @@ module ActiveRecord
0
           case
0
             when @reflection.options[:as]
0
               @finder_sql =
0
- "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{@owner.quoted_id} AND " +
0
+ "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{owner_quoted_id} AND " +
0
                 "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.base_class.name.to_s)}"
0
             else
0
- @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{@owner.quoted_id}"
0
+ @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{owner_quoted_id}"
0
           end
0
           @finder_sql << " AND (#{conditions})" if conditions
0
         end

Comments

    No one has commented yet.