Class: TeradataCli::FixStringType

Inherits:
FieldType
  • Object
show all
Defined in:
lib/teradata-cli/connection.rb

Overview

CHAR: fixed-length character string BYTE: fixed-length byte string

Instance Attribute Summary

Attributes inherited from FieldType

#format, #name, #title, #type_code, #type_name

Instance Method Summary collapse

Methods inherited from FieldType

code_names, codes, create, #initialize, #inspect, #to_s

Constructor Details

This class inherits a constructor from TeradataCli::FieldType

Instance Method Details

#unmarshal(f) ⇒ Object



889
890
891
892
893
894
895
896
897
# File 'lib/teradata-cli/connection.rb', line 889

def unmarshal(f)
  val = @extractor.extract(f.read(@length)).rstrip
  #FIXME why teradata cliv2 uses CHAR_NN for timestamps
  if /^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/ =~ val
    DateTime.parse("#{val[0,10]}T#{val[11,19]}") rescue nil
  else
    val
  end
end