Namespace

Included Modules

Files

Class/Module Index [+]

Quicksearch

ArJdbc::MSSQL::Column

@see ActiveRecord::ConnectionAdapters::JdbcColumn

Attributes

identity[RW]
is_special[RW]
special[RW]

Public Class Methods

included(base) click to toggle source
# File lib/arjdbc/mssql/column.rb, line 12
def self.included(base)
  # NOTE: assumes a standalone MSSQLColumn class
  class << base; include Cast; end
end

Public Instance Methods

default_value(value) click to toggle source

@override

# File lib/arjdbc/mssql/column.rb, line 44
def default_value(value)
  return $1 if value =~ /^\(N?'(.*)'\)$/
  value
end
extract_limit(sql_type) click to toggle source

@override

# File lib/arjdbc/mssql/column.rb, line 67
def extract_limit(sql_type)
  case sql_type
  when /^smallint/
    2
  when /^int/
    4
  when /^bigint/
    8
  when /\(max\)/, /decimal/, /numeric/
    nil
  when /text|ntext|xml|binary|image|varbinary|bit/
    nil
  else
    super
  end
end
simplified_type(field_type) click to toggle source

@override

# File lib/arjdbc/mssql/column.rb, line 24
def simplified_type(field_type)
  case field_type
  when /int|bigint|smallint|tinyint/           then :integer
  when /numeric/                               then (@scale.nil? || @scale == 0) ? :integer : :decimal
  when /float|double|money|real|smallmoney/    then :decimal
  when /datetime|smalldatetime/                then :datetime
  when /timestamp/                             then :timestamp
  when /time/                                  then :time
  when /date/                                  then :date
  when /text|ntext|xml/                        then :text
  when /binary|image|varbinary/                then :binary
  when /char|nchar|nvarchar|string|varchar/    then (@limit == 1073741823 ? (@limit = nil; :text) : :string)
  when /bit/                                   then :boolean
  when /uniqueidentifier/                      then :string
  else
    super
  end
end
type_cast(value) click to toggle source

@override

# File lib/arjdbc/mssql/column.rb, line 50
def type_cast(value)
  return nil if value.nil?
  case type
  when :integer then ( value.is_a?(String) ? unquote(value) : (value || 0) ).to_i
  when :primary_key then value.respond_to?(:to_i) ? value.to_i : ((value && 1) || 0)
  when :decimal   then self.class.value_to_decimal(unquote(value))
  when :date      then self.class.string_to_date(value)
  when :datetime  then self.class.string_to_time(value)
  when :timestamp then self.class.string_to_time(value)
  when :time      then self.class.string_to_dummy_time(value)
  when :boolean   then value == true || (value =~ /^t(rue)?$/) == 0 || unquote(value) == '1'
  when :binary    then unquote(value)
  else value
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.