Module: ActiveRecord::ConnectionAdapters::SQLServer::Quoting
- Included in:
 - ActiveRecord::ConnectionAdapters::SQLServerAdapter
 
- Defined in:
 - lib/active_record/connection_adapters/sqlserver/quoting.rb
 
Constant Summary collapse
- QUOTED_TRUE =
 "1".freeze
- QUOTED_FALSE =
 "0".freeze
- QUOTED_STRING_PREFIX =
 "N".freeze
Instance Method Summary collapse
- #column_name_matcher ⇒ Object
 - #column_name_with_order_matcher ⇒ Object
 - #fetch_type_metadata(sql_type, sqlserver_options = {}) ⇒ Object
 - #quote(value) ⇒ Object
 - #quote_column_name(name) ⇒ Object
 - #quote_default_expression(value, column) ⇒ Object
 - #quote_string(s) ⇒ Object
 - #quote_string_single(s) ⇒ Object
 - #quote_string_single_national(s) ⇒ Object
 - #quoted_date(value) ⇒ Object
 - #quoted_false ⇒ Object
 - #quoted_true ⇒ Object
 - #type_cast(value) ⇒ Object
 - #unquoted_false ⇒ Object
 - #unquoted_true ⇒ Object
 
Instance Method Details
#column_name_matcher ⇒ Object
      75 76 77  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 75 def column_name_matcher COLUMN_NAME end  | 
  
#column_name_with_order_matcher ⇒ Object
      79 80 81  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 79 def column_name_with_order_matcher COLUMN_NAME_WITH_ORDER end  | 
  
#fetch_type_metadata(sql_type, sqlserver_options = {}) ⇒ Object
      11 12 13 14 15 16 17 18 19 20 21 22  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 11 def (sql_type, = {}) cast_type = lookup_cast_type(sql_type) simple_type = SqlTypeMetadata.new( sql_type: sql_type, type: cast_type.type, limit: cast_type.limit, precision: cast_type.precision, scale: cast_type.scale ) SQLServer::TypeMetadata.new(simple_type, **) end  | 
  
#quote(value) ⇒ Object
      112 113 114 115 116 117 118 119 120 121 122 123  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 112 def quote(value) case value when Type::Binary::Data "0x#{value.hex}" when ActiveRecord::Type::SQLServer::Data value.quoted when String, ActiveSupport::Multibyte::Chars "#{QUOTED_STRING_PREFIX}#{super}" else super end end  | 
  
#quote_column_name(name) ⇒ Object
      36 37 38  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 36 def quote_column_name(name) SQLServer::Utils.extract_identifiers(name).quoted end  | 
  
#quote_default_expression(value, column) ⇒ Object
      40 41 42 43 44 45 46 47  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 40 def quote_default_expression(value, column) cast_type = lookup_cast_type(column.sql_type) if cast_type.type == :uuid && value =~ /\(\)/ value else super end end  | 
  
#quote_string(s) ⇒ Object
      24 25 26  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 24 def quote_string(s) SQLServer::Utils.quote_string(s) end  | 
  
#quote_string_single(s) ⇒ Object
      28 29 30  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 28 def quote_string_single(s) SQLServer::Utils.quote_string_single(s) end  | 
  
#quote_string_single_national(s) ⇒ Object
      32 33 34  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 32 def quote_string_single_national(s) SQLServer::Utils.quote_string_single_national(s) end  | 
  
#quoted_date(value) ⇒ Object
      65 66 67 68 69 70 71 72 73  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 65 def quoted_date(value) if value.acts_like?(:time) Type::DateTime.new.serialize(value) elsif value.acts_like?(:date) Type::Date.new.serialize(value) else value end end  | 
  
#quoted_false ⇒ Object
      57 58 59  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 57 def quoted_false QUOTED_FALSE end  | 
  
#quoted_true ⇒ Object
      49 50 51  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 49 def quoted_true QUOTED_TRUE end  | 
  
#type_cast(value) ⇒ Object
      125 126 127 128 129 130 131 132  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 125 def type_cast(value) case value when ActiveRecord::Type::SQLServer::Data value.to_s else super end end  | 
  
#unquoted_false ⇒ Object
      61 62 63  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 61 def unquoted_false 0 end  | 
  
#unquoted_true ⇒ Object
      53 54 55  | 
    
      # File 'lib/active_record/connection_adapters/sqlserver/quoting.rb', line 53 def unquoted_true 1 end  |