Changeset 175 for branches

Show
Ignore:
Timestamp:
10/09/07 16:31:51 (5 years ago)
Author:
yann
Message:

attributes_with_quotes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/yann/lib/globalize/localization/db_translate.rb

    r155 r175  
    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 
     
    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) 
     
    690690            end 
    691691          end 
     692                include_readonly_attributes ? quoted : remove_readonly_attributes(quoted) 
    692693        end 
    693694 
     
    766767        def find_every(options) 
    767768          return globalize_old_find_every(options) if options[:untranslated] 
    768            
     769 
    769770          # do quick version if base language is active 
    770771          if Locale.base? && !options.has_key?(:include_translated) 
     
    777778 
    778779          options[:conditions] = sanitize_sql(options[:conditions]) if options[:conditions] 
    779            
     780 
    780781          joins_clause = options[:joins].nil? ? "" : options[:joins].dup 
    781782          joins_args = [] 
    782783          load_full = options[:translate_all] 
    783784          facets = load_full ? globalize_facets : preload_facets 
    784            
     785 
    785786          if options[:select].nil? || options[:select] = '*' 
    786787            surrounding_clause = '%s' 
     
    791792              surrounding_clause = surrounding_clause.gsub(re_select, '%s') 
    792793            else 
    793               raise StandardError,  
     794              raise StandardError, 
    794795              "this :select option format is not allowed on translatable models " + 
    795796              "(#{options[:select]})" 
    796797            end 
    797798          end 
    798            
     799 
    799800          # there will at least be an +id+ field here 
    800801          select_clause = untranslated_fields.map {|f| "#{table_name}.#{f}" }.join(", ") 
    801            
     802 
    802803          if Locale.base? 
    803804            select_clause <<  ', ' << facets.map {|f| "#{table_name}.#{f}" }.join(", ")