teradata-cli 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/teradata-cli/connection.rb +29 -7
- data/lib/teradata-cli/version.rb +1 -1
- metadata +4 -4
@@ -14,6 +14,8 @@ require 'teradata-cli/exception'
|
|
14
14
|
require 'forwardable'
|
15
15
|
require 'stringio'
|
16
16
|
|
17
|
+
#require 'ruby-debug' #FIXME
|
18
|
+
|
17
19
|
module TeradataCli
|
18
20
|
|
19
21
|
class ConnectionError < CLIError; end
|
@@ -345,7 +347,7 @@ module TeradataCli
|
|
345
347
|
end
|
346
348
|
end
|
347
349
|
warn { "read_metadata: each_fet_parcel returned before PclENDSTATEMENT?" }
|
348
|
-
nil #
|
350
|
+
nil #FIXME: should raise?
|
349
351
|
end
|
350
352
|
|
351
353
|
def read_record
|
@@ -360,7 +362,7 @@ module TeradataCli
|
|
360
362
|
end
|
361
363
|
end
|
362
364
|
warn { "read_record: each_fet_parcel returned before PclENDSTATEMENT?" }
|
363
|
-
nil #
|
365
|
+
nil #FIXME: should raise?
|
364
366
|
end
|
365
367
|
|
366
368
|
def skip_current_statement
|
@@ -775,6 +777,7 @@ module TeradataCli
|
|
775
777
|
def unmarshal(data)
|
776
778
|
f = StringIO.new(data)
|
777
779
|
cols = @types.zip(read_indicator(f)).map {|type, is_null|
|
780
|
+
# debugger #FIXME
|
778
781
|
val = type.unmarshal(f) # We must read value regardless of NULL.
|
779
782
|
is_null ? nil : val
|
780
783
|
}
|
@@ -871,7 +874,7 @@ module TeradataCli
|
|
871
874
|
|
872
875
|
# default implementation: only read as string.
|
873
876
|
def unmarshal(f)
|
874
|
-
f.read(@length)
|
877
|
+
f.read(@length).rstrip
|
875
878
|
end
|
876
879
|
end
|
877
880
|
|
@@ -884,7 +887,13 @@ module TeradataCli
|
|
884
887
|
bind_code :BYTE_N, 693
|
885
888
|
|
886
889
|
def unmarshal(f)
|
887
|
-
@extractor.extract(f.read(@length))
|
890
|
+
val = @extractor.extract(f.read(@length)).rstrip
|
891
|
+
#FIXME why teradata cliv2 uses CHAR_NN for timestamps
|
892
|
+
if /^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/ =~ val
|
893
|
+
DateTime.parse("#{val[0,10]}T#{val[11,19]}") rescue nil
|
894
|
+
else
|
895
|
+
val
|
896
|
+
end
|
888
897
|
end
|
889
898
|
end
|
890
899
|
|
@@ -996,7 +1005,11 @@ module TeradataCli
|
|
996
1005
|
str
|
997
1006
|
else
|
998
1007
|
return '0.' + str if str.size == frac
|
999
|
-
|
1008
|
+
return '0.0' + str if str == "0"
|
1009
|
+
begin
|
1010
|
+
str[-frac, 0] = '.'
|
1011
|
+
rescue
|
1012
|
+
end
|
1000
1013
|
str
|
1001
1014
|
end
|
1002
1015
|
end
|
@@ -1008,11 +1021,20 @@ module TeradataCli
|
|
1008
1021
|
|
1009
1022
|
def unmarshal(f)
|
1010
1023
|
d = (f.read(@length).unpack('l').first + 19000000).to_s
|
1011
|
-
d[0,4] + '-' + d[4,2] + '-' + d[6,2]
|
1024
|
+
Date.parse(d[0,4] + '-' + d[4,2] + '-' + d[6,2]) rescue nil
|
1012
1025
|
end
|
1013
1026
|
end
|
1014
1027
|
|
1015
|
-
# TIME, TIMESTAMP
|
1028
|
+
# TIME, TIMESTAMP
|
1029
|
+
class DateTimeType < FieldType
|
1030
|
+
# bind_code :CHAR_NN, 452
|
1031
|
+
|
1032
|
+
def unmarshal(f)
|
1033
|
+
# debugger #FIXME
|
1034
|
+
dt = @extractor.extract(f.read(@length)) # "2013-10-10 16:44:39"
|
1035
|
+
DateTime.parse("#{dt[0,10]}T#{dt[11,19]}") rescue nil
|
1036
|
+
end
|
1037
|
+
end
|
1016
1038
|
|
1017
1039
|
|
1018
1040
|
class Record
|
data/lib/teradata-cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teradata-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 10
|
10
|
+
version: 0.0.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Giuseppe Privitera
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-10-
|
18
|
+
date: 2013-10-29 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: bundler
|