vertica 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/vertica.rb +1 -0
- data/lib/vertica/protocol/backend/row_description.rb +1 -1
- data/lib/vertica/protocol/frontend/startup.rb +10 -0
- data/lib/vertica/version.rb +1 -1
- data/test/functional/functional_connection_test.rb +14 -0
- data/test/functional/functional_query_test.rb +9 -0
- data/test/functional/functional_type_deserialization_test.rb +23 -23
- data/test/unit/data_type_test.rb +9 -9
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0398cb8bbec69cc6b41543713a14a9c6e31fa85b
|
4
|
+
data.tar.gz: 091b9160d100b08afec8c67d60e1db6c0322aaf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afa1900d1fc39aa59e0ecb6b7bd65aabab1731f6fe0690c6e7faab84921d9b4a4a0ca9d1e8b023ed040e7d909142f7183edf39ab341d2dec8a9798d35330123c
|
7
|
+
data.tar.gz: f12b5cf94046fed6ff269e5b9a932531aaf63899248505a61d88a754fbacaede3e03d31fc78ac62c8231bde33f23a9f338f16eecfbbb4e99068a9d8327335163
|
data/CHANGELOG.md
CHANGED
data/lib/vertica.rb
CHANGED
@@ -8,12 +8,22 @@ module Vertica
|
|
8
8
|
@user = user
|
9
9
|
@database = database
|
10
10
|
@options = options
|
11
|
+
@type = "vertica-rb"
|
12
|
+
@pid = Process.pid.to_s
|
13
|
+
@platform = RUBY_PLATFORM
|
14
|
+
@version = Vertica::VERSION
|
15
|
+
@label = "#{@type}-#{@version}-#{SecureRandom.uuid}"
|
11
16
|
end
|
12
17
|
|
13
18
|
def message_body
|
14
19
|
str = [Vertica::PROTOCOL_VERSION].pack('N')
|
15
20
|
str << ["user", @user].pack('Z*Z*') if @user
|
16
21
|
str << ["database", @database].pack('Z*Z*') if @database
|
22
|
+
str << ["client_type", @type].pack('Z*Z*')
|
23
|
+
str << ["client_pid", @pid].pack('Z*Z*')
|
24
|
+
str << ["client_os", @platform].pack('Z*Z*')
|
25
|
+
str << ["client_version", @version].pack('Z*Z*')
|
26
|
+
str << ["client_label", @label].pack('Z*Z*')
|
17
27
|
str << ["options", @options].pack('Z*Z*') if @options
|
18
28
|
str << [].pack('x')
|
19
29
|
end
|
data/lib/vertica/version.rb
CHANGED
@@ -9,6 +9,20 @@ class FunctionalConnectionTest < Minitest::Test
|
|
9
9
|
assert_valid_closed_connection(connection)
|
10
10
|
end
|
11
11
|
|
12
|
+
def test_connection_client_info
|
13
|
+
connection = Vertica::Connection.new(TEST_CONNECTION_HASH)
|
14
|
+
|
15
|
+
connection.query("SELECT client_type, client_os, client_version, client_label FROM SESSIONS WHERE client_pid = #{Vertica.quote(Process.pid)}") do |row|
|
16
|
+
assert_equal "vertica-rb", row['client_type']
|
17
|
+
assert_equal RUBY_PLATFORM, row['client_os']
|
18
|
+
assert_equal Vertica::VERSION, row['client_version']
|
19
|
+
assert_match "vertica-rb-#{Vertica::VERSION}-", row['client_label']
|
20
|
+
end
|
21
|
+
|
22
|
+
connection.close
|
23
|
+
assert_valid_closed_connection(connection)
|
24
|
+
end
|
25
|
+
|
12
26
|
def test_connection_with_ssl
|
13
27
|
connection = Vertica::Connection.new(ssl: true, **TEST_CONNECTION_HASH)
|
14
28
|
assert_valid_open_connection(connection)
|
@@ -72,6 +72,15 @@ class FunctionalQueryTest < Minitest::Test
|
|
72
72
|
assert_empty r
|
73
73
|
end
|
74
74
|
|
75
|
+
def test_select_query_with_multibyte_column_names_results
|
76
|
+
r = @connection.query("SELECT 1 as \"イチ\", 2 as \"ニ\"")
|
77
|
+
assert_equal 1, r.size
|
78
|
+
assert_equal 2, r.row_description.length
|
79
|
+
|
80
|
+
assert_equal 'イチ', r.row_description[0].name
|
81
|
+
assert_equal 'ニ', r.row_description[1].name
|
82
|
+
end
|
83
|
+
|
75
84
|
def test_insert
|
76
85
|
r = @connection.query("INSERT INTO test_ruby_vertica_table VALUES (2, 'stefanie')")
|
77
86
|
assert_equal "INSERT", r.tag
|
@@ -52,20 +52,20 @@ class FunctionalTypeDeserializationTest < Minitest::Test
|
|
52
52
|
|
53
53
|
result = @connection.query("SELECT * FROM conversions_table LIMIT 1")
|
54
54
|
|
55
|
-
assert_equal
|
56
|
-
assert_equal
|
57
|
-
assert_equal
|
58
|
-
assert_equal
|
59
|
-
assert_equal
|
60
|
-
assert_equal
|
61
|
-
assert_equal
|
62
|
-
assert_equal
|
63
|
-
assert_equal
|
64
|
-
assert_equal
|
65
|
-
assert_equal
|
66
|
-
assert_equal
|
67
|
-
assert_equal
|
68
|
-
assert_equal
|
55
|
+
assert_equal(1, result.size)
|
56
|
+
assert_equal(123, result.fetch(0, 'int_field'))
|
57
|
+
assert_equal('hello world', result.fetch(0, 'varchar_field'))
|
58
|
+
assert_equal('hello ', result.fetch(0, 'char_field'))
|
59
|
+
assert_equal('hello world', result.fetch(0, 'long_varchar_field'))
|
60
|
+
assert_equal(Date.parse('2010-01-01'), result.fetch(0, 'date_field'))
|
61
|
+
assert_equal(Time.new(2010, 1, 1, 12, 0, BigDecimal.new("0.123456")), result.fetch(0, 'timestamp_field'))
|
62
|
+
assert_equal(Time.new(2010, 1, 1, 12, 0, 0, '+09:30'), result.fetch(0, 'timestamptz_field'))
|
63
|
+
assert_equal("12:00:00", result.fetch(0, 'time_field'))
|
64
|
+
assert_equal("1", result.fetch(0, 'interval_field'))
|
65
|
+
assert_equal(true, result.fetch(0, 'boolean_field'))
|
66
|
+
assert_equal(-1.123, result.fetch(0, 'float_field'))
|
67
|
+
assert_equal(BigDecimal.new('1.12'), result.fetch(0, 'numeric_field'))
|
68
|
+
assert_equal(['d09fd180d0b8d0b2d0b5d1822c2068656c6c6f21'].pack('H*'), result.fetch(0, 'binary_field'))
|
69
69
|
end
|
70
70
|
|
71
71
|
def test_nil_values_from_table
|
@@ -87,15 +87,15 @@ class FunctionalTypeDeserializationTest < Minitest::Test
|
|
87
87
|
NULL::float
|
88
88
|
SQL
|
89
89
|
|
90
|
-
assert_equal
|
91
|
-
assert_equal
|
92
|
-
assert_equal
|
93
|
-
assert_equal
|
94
|
-
assert_equal
|
95
|
-
assert_equal
|
96
|
-
assert_equal
|
97
|
-
assert
|
98
|
-
assert_nil
|
90
|
+
assert_equal(1, result.size)
|
91
|
+
assert_equal(0.0, result[0, 0])
|
92
|
+
assert_equal(-0.0, result[0, 1])
|
93
|
+
assert_equal(1.1, result[0, 2])
|
94
|
+
assert_equal(-1.1, result[0, 3])
|
95
|
+
assert_equal(Float::INFINITY, result[0, 4])
|
96
|
+
assert_equal(-Float::INFINITY, result[0, 5])
|
97
|
+
assert(result[0, 6].equal?(Float::NAN), "NaN should be derialized properly")
|
98
|
+
assert_nil(result[0, 7])
|
99
99
|
end
|
100
100
|
|
101
101
|
def test_deserialize_numeric_values
|
data/test/unit/data_type_test.rb
CHANGED
@@ -30,21 +30,21 @@ class DataTypeTest < Minitest::Test
|
|
30
30
|
def test_deserialize_integer
|
31
31
|
type = Vertica::DataType.build(oid: 6)
|
32
32
|
|
33
|
-
assert_nil
|
34
|
-
assert_equal
|
35
|
-
assert_equal
|
33
|
+
assert_nil(type.deserialize(nil))
|
34
|
+
assert_equal(0, type.deserialize('0'))
|
35
|
+
assert_equal(-123, type.deserialize('-123'))
|
36
36
|
assert_raises(ArgumentError) { type.deserialize('foo') }
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_deserialize_float
|
40
40
|
type = Vertica::DataType.build(oid: 7)
|
41
41
|
|
42
|
-
assert_nil
|
43
|
-
assert_equal
|
44
|
-
assert_equal
|
45
|
-
assert
|
46
|
-
assert_equal
|
47
|
-
assert_equal
|
42
|
+
assert_nil(type.deserialize(nil))
|
43
|
+
assert_equal(Float::INFINITY, type.deserialize('Infinity'))
|
44
|
+
assert_equal(-Float::INFINITY, type.deserialize('-Infinity'))
|
45
|
+
assert(type.deserialize('NaN').equal?(Float::NAN), "NaN should be deserialized as Float::NAN")
|
46
|
+
assert_equal(1.1, type.deserialize('1.1'))
|
47
|
+
assert_equal(-1.1, type.deserialize('-1.1'))
|
48
48
|
assert_raises(ArgumentError) { type.deserialize('foo') }
|
49
49
|
end
|
50
50
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vertica
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Smick
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2017-04-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -187,4 +187,3 @@ test_files:
|
|
187
187
|
- test/unit/result_test.rb
|
188
188
|
- test/unit/row_description_test.rb
|
189
189
|
- test/unit/row_test.rb
|
190
|
-
has_rdoc:
|