Ticket #184: attributes_with_quotes-2_0.patch

File attributes_with_quotes-2_0.patch, 1.5 kB (added by artemv, 8 months ago)
  • lib/globalize/localization/db_translate.rb

    old new  
    672672        # an SQL statement. 
    673673        # REDEFINED to include only untranslated fields. We don't want to overwrite the 
    674674        # base translation with other translations. 
    675         def attributes_with_quotes(include_primary_key = true) 
     675        def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = true)           
    676676          if Locale.base? 
    677             attributes.inject({}) do |quoted, (name, value)| 
     677            quoted = attributes.inject({}) do |quoted, (name, value)| 
    678678              if column = column_for_attribute(name) 
    679679                quoted[name] = quote_value(value, column) unless !include_primary_key && column.primary 
    680680              end 
    681681              quoted 
    682682            end 
    683683          else 
    684             attributes.inject({}) do |quoted, (name, value)| 
     684            quoted = attributes.inject({}) do |quoted, (name, value)| 
    685685              if !self.class.globalize_facets_hash.has_key?(name) && 
    686686                  column = column_for_attribute(name) 
    687687                quoted[name] = quote_value(value, column) unless !include_primary_key && column.primary 
     
    689689              quoted 
    690690            end 
    691691          end 
     692          include_readonly_attributes ? quoted : remove_readonly_attributes(quoted) 
    692693        end 
    693694 
    694695        def create_or_update