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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df3c0da7b3f06ebefc1510848802b932c951a289
4
- data.tar.gz: 2ad214b56cf565eae9ae3d4c56dfdac202fece83
3
+ metadata.gz: 0398cb8bbec69cc6b41543713a14a9c6e31fa85b
4
+ data.tar.gz: 091b9160d100b08afec8c67d60e1db6c0322aaf1
5
5
  SHA512:
6
- metadata.gz: 32f0269fcdc0e18f4a75b2cd515eddf85805e8f28f12b05a570e5227cc99152a46ef2e55560e4ab038fcdb359858ad19611319aa7bbc7faaf001a3598e897219
7
- data.tar.gz: 21057ff1fd1aeb04b52de43c2a5f8e6d6ebc32d4e757608dc8dbba4f237f78ee2a8b828dadecb35893a358c6f68902e6cc65bf08eaa9bcee54fc722293bfa620
6
+ metadata.gz: afa1900d1fc39aa59e0ecb6b7bd65aabab1731f6fe0690c6e7faab84921d9b4a4a0ca9d1e8b023ed040e7d909142f7183edf39ab341d2dec8a9798d35330123c
7
+ data.tar.gz: f12b5cf94046fed6ff269e5b9a932531aaf63899248505a61d88a754fbacaede3e03d31fc78ac62c8231bde33f23a9f338f16eecfbbb4e99068a9d8327335163
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 1.0.2
4
+
5
+ - Send more client information when connecting, so an admin knows who is connected.
6
+
3
7
  ## Version 1.0.1
4
8
 
5
9
  - Fix an issue that made connecting over SSL not work.
@@ -1,6 +1,7 @@
1
1
  require 'date'
2
2
  require 'time'
3
3
  require 'bigdecimal'
4
+ require 'securerandom'
4
5
 
5
6
  # Main module for this library. It contains the {.connect} method to return a
6
7
  # {Vertica::Connection} instance, and methods to quote values ({.quote}) and
@@ -21,7 +21,7 @@ module Vertica
21
21
  :data_format => field_info[6],
22
22
  }
23
23
 
24
- pos += 19 + field_info[0].size
24
+ pos += 19 + field_info[0].bytesize
25
25
  end
26
26
  end
27
27
  end
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Vertica
2
2
  # The version of the package. We adhere to semantic versioning.
3
3
  # To release a new version, update this constant, commit to master, and run `rake release`
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.3"
5
5
  end
@@ -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 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')
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 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)
98
- assert_nil result[0, 7]
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
@@ -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 type.deserialize(nil)
34
- assert_equal 0, type.deserialize('0')
35
- assert_equal -123, type.deserialize('-123')
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 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)
46
- assert_equal 1.1, type.deserialize('1.1')
47
- assert_equal -1.1, type.deserialize('-1.1')
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.1
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: 2016-10-06 00:00:00.000000000 Z
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: