module ActiveRecord::ConnectionAdapters::SQLServer::Quoting

Constants

COLUMN_NAME
COLUMN_NAME_WITH_ORDER

Public Instance Methods

column_name_matcher() click to toggle source
# File lib/active_record/connection_adapters/sqlserver/quoting.rb, line 79
def column_name_matcher
  COLUMN_NAME
end
column_name_with_order_matcher() click to toggle source
# File lib/active_record/connection_adapters/sqlserver/quoting.rb, line 83
def column_name_with_order_matcher
  COLUMN_NAME_WITH_ORDER
end
fetch_type_metadata(sql_type, sqlserver_options = {}) click to toggle source
# File lib/active_record/connection_adapters/sqlserver/quoting.rb, line 10
def fetch_type_metadata(sql_type, sqlserver_options = {})
  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, **sqlserver_options)
end
quote(value) click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/sqlserver/quoting.rb, line 117
def quote(value)
  case value
  when Type::Binary::Data
    "0x#{value.hex}"
  when ActiveRecord::Type::SQLServer::Data
    value.quoted
  when String, ActiveSupport::Multibyte::Chars
    "N#{super}"
  else
    super
  end
end
quote_column_name(name) click to toggle source
# File lib/active_record/connection_adapters/sqlserver/quoting.rb, line 36
def quote_column_name(name)
  QUOTED_COLUMN_NAMES[name] ||= SQLServer::Utils.extract_identifiers(name).quoted
end
quote_default_expression(value, column) click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/sqlserver/quoting.rb, line 44
def quote_default_expression(value, column)
  cast_type = lookup_cast_type(column.sql_type)
  if cast_type.type == :uuid && value.is_a?(String) && value.include?('()')
    value
  else
    super
  end
end
quote_string(s) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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
quote_table_name(name) click to toggle source
# File lib/active_record/connection_adapters/sqlserver/quoting.rb, line 40
def quote_table_name(name)
  QUOTED_TABLE_NAMES[name] ||= SQLServer::Utils.extract_identifiers(name).quoted
end
quoted_date(value) click to toggle source
# File lib/active_record/connection_adapters/sqlserver/quoting.rb, line 69
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() click to toggle source
# File lib/active_record/connection_adapters/sqlserver/quoting.rb, line 61
def quoted_false
  '0'
end
quoted_true() click to toggle source
# File lib/active_record/connection_adapters/sqlserver/quoting.rb, line 53
def quoted_true
  '1'
end
type_cast(value) click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/sqlserver/quoting.rb, line 130
def type_cast(value)
  case value
  when ActiveRecord::Type::SQLServer::Data
    value.to_s
  else
    super
  end
end
unquoted_false() click to toggle source
# File lib/active_record/connection_adapters/sqlserver/quoting.rb, line 65
def unquoted_false
  0
end
unquoted_true() click to toggle source
# File lib/active_record/connection_adapters/sqlserver/quoting.rb, line 57
def unquoted_true
  1
end