vertica 0.9.0.beta5 → 0.9.0.beta6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.0.beta5
1
+ 0.9.0.beta6
@@ -6,6 +6,8 @@ module Vertica
6
6
  attr_reader :size
7
7
  attr_reader :data_type
8
8
 
9
+ STRING_CONVERTER = String.new.respond_to?(:force_encoding) ? lambda { |s| s.force_encoding('utf-8') } : nil
10
+
9
11
  DATA_TYPE_CONVERSIONS = [
10
12
  [:unspecified, nil],
11
13
  [:tuple, nil],
@@ -15,8 +17,8 @@ module Vertica
15
17
  [:bool, lambda { |s| s == 't' }],
16
18
  [:integer, lambda { |s| s.to_i }],
17
19
  [:float, lambda { |s| s.to_f }],
18
- [:char, nil],
19
- [:varchar, nil],
20
+ [:char, STRING_CONVERTER],
21
+ [:varchar, STRING_CONVERTER],
20
22
  [:date, lambda { |s| Date.new(*s.split("-").map{|x| x.to_i}) }],
21
23
  [:time, nil],
22
24
  [:timestamp, lambda { |s| DateTime.parse(s, true) }],
@@ -37,7 +37,7 @@ class Vertica::Connection
37
37
  @socket ||= begin
38
38
  raw_socket = TCPSocket.new(@options[:host], @options[:port].to_i)
39
39
  if @options[:ssl]
40
- require 'openssl/ssl'
40
+ require 'openssl'
41
41
  raw_socket.write Vertica::Messages::SslRequest.new.to_bytes
42
42
  if raw_socket.read(1) == 'S'
43
43
  raw_socket = OpenSSL::SSL::SSLSocket.new(raw_socket, OpenSSL::SSL::SSLContext.new)
@@ -43,6 +43,18 @@ class Vertica::Result
43
43
  @rows.each(&block)
44
44
  end
45
45
 
46
+ def empty?
47
+ @rows.empty?
48
+ end
49
+
50
+ def the_value
51
+ if empty?
52
+ nil
53
+ else
54
+ @row_style == :array ? rows[0][0] : rows[0][columns[0].name]
55
+ end
56
+ end
57
+
46
58
  alias_method :each, :each_row
47
59
 
48
60
  def row_count
@@ -1,3 +1,4 @@
1
+ # encoding : UTF-8
1
2
  require 'test_helper'
2
3
 
3
4
  class ValueConversionTest < Test::Unit::TestCase
@@ -44,4 +45,8 @@ class ValueConversionTest < Test::Unit::TestCase
44
45
  assert_equal result.rows.length, 1
45
46
  assert_equal [nil, nil, nil, nil, nil, nil, nil], result.rows.first
46
47
  end
48
+
49
+ def test_string_encoding
50
+ assert_equal 'åßç∂ë', @connection.query("SELECT 'åßç∂ë'").the_value
51
+ end
47
52
  end
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: 0.9.0.beta5
4
+ version: 0.9.0.beta6
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -11,12 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-11-04 00:00:00.000000000 -04:00
15
- default_executable:
14
+ date: 2011-11-09 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: rake
19
- requirement: &2153854620 !ruby/object:Gem::Requirement
18
+ requirement: &2165802180 !ruby/object:Gem::Requirement
20
19
  none: false
21
20
  requirements:
22
21
  - - ! '>='
@@ -24,10 +23,10 @@ dependencies:
24
23
  version: '0'
25
24
  type: :runtime
26
25
  prerelease: false
27
- version_requirements: *2153854620
26
+ version_requirements: *2165802180
28
27
  - !ruby/object:Gem::Dependency
29
28
  name: jeweler
30
- requirement: &2153854060 !ruby/object:Gem::Requirement
29
+ requirement: &2165801500 !ruby/object:Gem::Requirement
31
30
  none: false
32
31
  requirements:
33
32
  - - ! '>='
@@ -35,7 +34,7 @@ dependencies:
35
34
  version: '0'
36
35
  type: :runtime
37
36
  prerelease: false
38
- version_requirements: *2153854060
37
+ version_requirements: *2165801500
39
38
  description: Query Vertica with ruby
40
39
  email: sprsquish@gmail.com
41
40
  executables: []
@@ -97,7 +96,6 @@ files:
97
96
  - test/unit/backend_message_test.rb
98
97
  - test/unit/frontend_message_test.rb
99
98
  - test/unit/quoting_test.rb
100
- has_rdoc: true
101
99
  homepage: http://github.com/sprsquish/vertica
102
100
  licenses: []
103
101
  post_install_message:
@@ -118,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
116
  version: 1.3.1
119
117
  requirements: []
120
118
  rubyforge_project:
121
- rubygems_version: 1.6.2
119
+ rubygems_version: 1.8.10
122
120
  signing_key:
123
121
  specification_version: 3
124
122
  summary: Pure ruby library for interacting with Vertica