do_mysql 0.10.3-x86-mingw32 → 0.10.4.rc1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -69,21 +69,19 @@ end
69
69
  have_func('localtime_r')
70
70
  have_func('gmtime_r')
71
71
 
72
- unless RUBY_PLATFORM =~ /mswin|mingw/
73
- have_header 'mysql.h'
74
- have_const 'MYSQL_TYPE_STRING', 'mysql.h'
75
- have_const 'MYSQL_TYPE_BIT', 'mysql.h'
76
- have_const 'MYSQL_TYPE_NEWDECIMAL', 'mysql.h'
77
- have_func 'mysql_query', 'mysql.h'
78
- have_func 'mysql_ssl_set', 'mysql.h'
79
- have_func 'mysql_sqlstate', 'mysql.h'
80
- have_func 'mysql_get_ssl_cipher', 'mysql.h'
81
- have_func 'mysql_set_character_set', 'mysql.h'
82
- have_func 'mysql_get_server_version', 'mysql.h'
83
- have_struct_member 'MYSQL_FIELD', 'charsetnr', 'mysql.h'
84
- end
72
+ have_header 'mysql.h'
73
+ have_const 'MYSQL_TYPE_STRING', 'mysql.h'
74
+ have_const 'MYSQL_TYPE_BIT', 'mysql.h'
75
+ have_const 'MYSQL_TYPE_NEWDECIMAL', 'mysql.h'
76
+ have_func 'mysql_query', 'mysql.h'
77
+ have_func 'mysql_ssl_set', 'mysql.h'
78
+ have_func 'mysql_sqlstate', 'mysql.h'
79
+ have_func 'mysql_get_ssl_cipher', 'mysql.h'
80
+ have_func 'mysql_set_character_set', 'mysql.h'
81
+ have_func 'mysql_get_server_version', 'mysql.h'
82
+ have_struct_member 'MYSQL_FIELD', 'charsetnr', 'mysql.h'
85
83
 
86
- $CFLAGS << ' -Wall ' unless RUBY_PLATFORM =~ /mswin/
84
+ $CFLAGS << ' -Wall '
87
85
 
88
86
  if RUBY_VERSION < '1.8.6'
89
87
  $CFLAGS << ' -DRUBY_LESS_THAN_186'
data/lib/do_mysql.rb CHANGED
@@ -3,9 +3,14 @@ if RUBY_PLATFORM =~ /java/
3
3
  require 'do_jdbc'
4
4
  require 'java'
5
5
 
6
- driver = 'com.mysql.jdbc.Driver'
6
+ module DataObjects
7
+ module Mysql
8
+ JDBC_DRIVER = 'com.mysql.jdbc.Driver'
9
+ end
10
+ end
11
+
7
12
  begin
8
- java.lang.Thread.currentThread.getContextClassLoader().loadClass(driver, true)
13
+ java.lang.Thread.currentThread.getContextClassLoader().loadClass(DataObjects::Mysql::JDBC_DRIVER, true)
9
14
  rescue
10
15
  require 'jdbc/mysql' # the JDBC driver, packaged as a gem
11
16
  end
@@ -15,7 +20,7 @@ if RUBY_PLATFORM =~ /java/
15
20
  # Thread.currentThread.getContextClassLoader().loadClass() within the
16
21
  # data_objects.Connection Java class, which is currently not working as
17
22
  # expected.
18
- java_import driver
23
+ java_import DataObjects::Mysql::JDBC_DRIVER
19
24
 
20
25
  end
21
26
 
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  module DataObjects
2
2
  module Mysql
3
- VERSION = '0.10.3'
3
+ VERSION = '0.10.4.rc1'
4
4
  end
5
5
  end
data/spec/command_spec.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
4
- require 'data_objects/spec/command_spec'
4
+ require 'data_objects/spec/shared/command_spec'
5
5
 
6
6
  describe DataObjects::Mysql::Command do
7
- behaves_like 'a Command'
8
- behaves_like 'a Command with async'
7
+ it_should_behave_like 'a Command'
8
+ it_should_behave_like 'a Command with async'
9
9
  end
@@ -1,26 +1,26 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
4
- require 'data_objects/spec/connection_spec'
4
+ require 'data_objects/spec/shared/connection_spec'
5
5
  require 'cgi'
6
6
 
7
7
  describe DataObjects::Mysql::Connection do
8
8
 
9
- before do
10
- @driver = CONFIG.scheme
11
- @user = CONFIG.user
9
+ before :all do
10
+ @driver = CONFIG.scheme
11
+ @user = CONFIG.user
12
12
  @password = CONFIG.pass
13
- @host = CONFIG.host
14
- @port = CONFIG.port
13
+ @host = CONFIG.host
14
+ @port = CONFIG.port
15
15
  @database = CONFIG.database
16
- @ssl = CONFIG.ssl
16
+ @ssl = CONFIG.ssl
17
17
  end
18
18
 
19
- behaves_like 'a Connection'
20
- behaves_like 'a Connection with authentication support'
21
- # FIXME: behaves_like 'a Connection with JDBC URL support' if JRUBY
22
- behaves_like 'a Connection with SSL support' unless JRUBY
23
- behaves_like 'a Connection via JDNI' if JRUBY
19
+ it_should_behave_like 'a Connection'
20
+ it_should_behave_like 'a Connection with authentication support'
21
+ it_should_behave_like 'a Connection with JDBC URL support' if JRUBY
22
+ it_should_behave_like 'a Connection with SSL support' unless JRUBY
23
+ it_should_behave_like 'a Connection via JDNI' if JRUBY
24
24
 
25
25
  if DataObjectsSpecHelpers.test_environment_supports_ssl?
26
26
 
@@ -28,22 +28,22 @@ describe DataObjects::Mysql::Connection do
28
28
 
29
29
  it 'should raise an error when passed ssl=true' do
30
30
  lambda { DataObjects::Connection.new("#{CONFIG.uri}?ssl=true") }.
31
- should.raise(ArgumentError)
31
+ should raise_error(ArgumentError)
32
32
  end
33
33
 
34
34
  it 'should raise an error when passed a nonexistent client certificate' do
35
35
  lambda { DataObjects::Connection.new("#{CONFIG.uri}?ssl[client_cert]=nonexistent") }.
36
- should.raise(ArgumentError)
36
+ should raise_error(ArgumentError)
37
37
  end
38
38
 
39
39
  it 'should raise an error when passed a nonexistent client key' do
40
40
  lambda { DataObjects::Connection.new("#{CONFIG.uri}?ssl[client_key]=nonexistent") }.
41
- should.raise(ArgumentError)
41
+ should raise_error(ArgumentError)
42
42
  end
43
43
 
44
44
  it 'should raise an error when passed a nonexistent ca certificate' do
45
45
  lambda { DataObjects::Connection.new("#{CONFIG.uri}?ssl[ca_cert]=nonexistent") }.
46
- should.raise(ArgumentError)
46
+ should raise_error(ArgumentError)
47
47
  end
48
48
 
49
49
  it 'should connect with a specified SSL cipher' do
@@ -53,7 +53,7 @@ describe DataObjects::Mysql::Connection do
53
53
 
54
54
  it 'should raise an error with an invalid SSL cipher' do
55
55
  lambda { DataObjects::Connection.new("#{CONFIG.uri}?#{CONFIG.ssl}&ssl[cipher]=invalid") }.
56
- should.raise
56
+ should raise_error
57
57
  end
58
58
 
59
59
  end
@@ -1,10 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
4
- require 'data_objects/spec/encoding_spec'
4
+ require 'data_objects/spec/shared/encoding_spec'
5
5
 
6
6
  describe DataObjects::Mysql::Connection do
7
- behaves_like 'a driver supporting different encodings'
8
- behaves_like 'returning correctly encoded strings for the default database encoding'
9
- behaves_like 'returning correctly encoded strings for the default internal encoding'
7
+ it_should_behave_like 'a driver supporting different encodings'
8
+ it_should_behave_like 'returning correctly encoded strings for the default database encoding'
9
+ it_should_behave_like 'returning correctly encoded strings for the default internal encoding'
10
10
  end
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/error/sql_error_spec'
4
+ require 'data_objects/spec/shared/error/sql_error_spec'
5
5
 
6
6
  describe 'DataObjects::Mysql raising SQLError' do
7
- behaves_like 'raising a SQLError'
7
+ it_should_behave_like 'raising a SQLError'
8
8
  end
data/spec/reader_spec.rb CHANGED
@@ -1,8 +1,34 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
4
- require 'data_objects/spec/reader_spec'
4
+ require 'data_objects/spec/shared/reader_spec'
5
5
 
6
6
  describe DataObjects::Mysql::Reader do
7
- behaves_like 'a Reader'
7
+ it_should_behave_like 'a Reader'
8
+
9
+ describe 'reading database metadata' do
10
+
11
+ subject { reader }
12
+
13
+ let(:connection) { DataObjects::Connection.new(CONFIG.uri) }
14
+ let(:command) { connection.create_command(sql) }
15
+ let(:reader) { command.execute_reader }
16
+
17
+ after do
18
+ reader.close
19
+ connection.close
20
+ end
21
+
22
+ describe 'showing correct column field names for a table' do
23
+ let(:sql) { 'SHOW COLUMNS FROM `widgets`' }
24
+ its(:fields) { should == [ "Field", "Type", "Null", "Key", "Default", "Extra" ] }
25
+ end
26
+
27
+ describe 'showing correct column field names for variables' do
28
+ let(:sql) { "SHOW VARIABLES LIKE 'character_set_connection'" }
29
+ its(:fields) { should == [ 'Variable_name', 'Value' ] }
30
+ end
31
+
32
+ end
33
+
8
34
  end
data/spec/result_spec.rb CHANGED
@@ -1,17 +1,17 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
4
- require 'data_objects/spec/result_spec'
4
+ require 'data_objects/spec/shared/result_spec'
5
5
 
6
6
  # splitting the descibe into two separate declaration avoids
7
- # concurrent execution of the "behaves_like ....."
7
+ # concurrent execution of the "it_should_behave_like ....."
8
8
  # needed by some databases (sqlite3)
9
9
 
10
10
  describe DataObjects::Mysql::Result do
11
- behaves_like 'a Result'
11
+ it_should_behave_like 'a Result'
12
12
  end
13
13
 
14
14
  describe DataObjects::Mysql::Result do
15
- behaves_like 'a Result which returns inserted key with sequences'
16
- behaves_like 'a Result which returns nil without sequences'
15
+ it_should_behave_like 'a Result which returns inserted key with sequences'
16
+ it_should_behave_like 'a Result which returns nil without sequences'
17
17
  end
data/spec/spec_helper.rb CHANGED
@@ -2,6 +2,7 @@ $TESTING=true
2
2
  JRUBY = RUBY_PLATFORM =~ /java/
3
3
 
4
4
  require 'rubygems'
5
+ require 'rspec'
5
6
  require 'date'
6
7
  require 'ostruct'
7
8
  require 'fileutils'
@@ -19,13 +20,15 @@ repo_root = File.expand_path('../../..', __FILE__)
19
20
  end
20
21
 
21
22
  require 'data_objects'
22
- require 'data_objects/spec/bacon'
23
- require 'data_objects/spec/helpers/ssl'
23
+ require 'data_objects/spec/setup'
24
+ require 'data_objects/spec/lib/ssl'
25
+ require 'data_objects/spec/lib/pending_helpers'
24
26
  require 'do_mysql'
25
27
 
26
28
  DataObjects::Mysql.logger = DataObjects::Logger.new(STDOUT, :off)
27
29
  at_exit { DataObjects.logger.flush }
28
30
 
31
+
29
32
  CONFIG = OpenStruct.new
30
33
  CONFIG.scheme = 'mysql'
31
34
  CONFIG.user = ENV['DO_MYSQL_USER'] || 'root'
@@ -40,8 +43,11 @@ CONFIG.port = ENV['DO_MYSQL_PORT'] || '3306'
40
43
  CONFIG.database = ENV['DO_MYSQL_DATABASE'] || '/do_test'
41
44
  CONFIG.ssl = SSLHelpers.query(:ca_cert, :client_cert, :client_key)
42
45
 
43
- CONFIG.uri = ENV["DO_MYSQL_SPEC_URI"] ||"#{CONFIG.scheme}://#{CONFIG.user_info}#{CONFIG.host}:#{CONFIG.port}#{CONFIG.database}"
44
- CONFIG.sleep = "SELECT sleep(1)"
46
+ CONFIG.driver = 'mysql'
47
+ CONFIG.jdbc_driver = DataObjects::Mysql.const_get('JDBC_DRIVER') rescue nil
48
+ CONFIG.uri = ENV["DO_MYSQL_SPEC_URI"] || "#{CONFIG.scheme}://#{CONFIG.user_info}#{CONFIG.host}:#{CONFIG.port}#{CONFIG.database}"
49
+ CONFIG.jdbc_uri = "jdbc:#{CONFIG.uri}"
50
+ CONFIG.sleep = "SELECT sleep(1)"
45
51
 
46
52
  module DataObjectsSpecHelpers
47
53
 
@@ -218,4 +224,7 @@ module DataObjectsSpecHelpers
218
224
 
219
225
  end
220
226
 
221
- include DataObjectsSpecHelpers
227
+ RSpec.configure do |config|
228
+ config.include(DataObjectsSpecHelpers)
229
+ config.include(DataObjects::Spec::PendingHelpers)
230
+ end
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/array_spec'
4
+ require 'data_objects/spec/shared/typecast/array_spec'
5
5
 
6
6
  describe 'DataObjects::Mysql with Array' do
7
- behaves_like 'supporting Array'
7
+ it_should_behave_like 'supporting Array'
8
8
  end
@@ -1,9 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/bigdecimal_spec'
4
+ require 'data_objects/spec/shared/typecast/bigdecimal_spec'
5
5
 
6
6
  describe 'DataObjects::Mysql with BigDecimal' do
7
- behaves_like 'supporting BigDecimal'
8
- behaves_like 'supporting BigDecimal autocasting'
7
+ it_should_behave_like 'supporting BigDecimal'
8
+ it_should_behave_like 'supporting BigDecimal autocasting'
9
9
  end
@@ -1,9 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/boolean_spec'
4
+ require 'data_objects/spec/shared/typecast/boolean_spec'
5
5
 
6
6
  describe 'DataObjects::Mysql with Boolean' do
7
- behaves_like 'supporting Boolean'
8
- behaves_like 'supporting Boolean autocasting'
7
+ it_should_behave_like 'supporting Boolean'
8
+ it_should_behave_like 'supporting Boolean autocasting'
9
9
  end
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/byte_array_spec'
4
+ require 'data_objects/spec/shared/typecast/byte_array_spec'
5
5
 
6
6
  describe 'DataObjects::Mysql with ByteArray' do
7
- behaves_like 'supporting ByteArray'
7
+ it_should_behave_like 'supporting ByteArray'
8
8
  end
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/class_spec'
4
+ require 'data_objects/spec/shared/typecast/class_spec'
5
5
 
6
6
  describe 'DataObjects::Mysql with Class' do
7
- behaves_like 'supporting Class'
7
+ it_should_behave_like 'supporting Class'
8
8
  end
@@ -1,9 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/date_spec'
4
+ require 'data_objects/spec/shared/typecast/date_spec'
5
5
 
6
6
  describe 'DataObjects::Mysql with Date' do
7
- behaves_like 'supporting Date'
8
- behaves_like 'supporting Date autocasting'
7
+ it_should_behave_like 'supporting Date'
8
+ it_should_behave_like 'supporting Date autocasting'
9
9
  end
@@ -1,9 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/datetime_spec'
4
+ require 'data_objects/spec/shared/typecast/datetime_spec'
5
5
 
6
6
  describe 'DataObjects::Mysql with DateTime' do
7
- behaves_like 'supporting DateTime'
8
- behaves_like 'supporting DateTime autocasting'
7
+ it_should_behave_like 'supporting DateTime'
8
+ it_should_behave_like 'supporting DateTime autocasting'
9
9
  end
@@ -1,9 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/float_spec'
4
+ require 'data_objects/spec/shared/typecast/float_spec'
5
5
 
6
6
  describe 'DataObjects::Mysql with Float' do
7
- behaves_like 'supporting Float'
8
- behaves_like 'supporting Float autocasting'
7
+ it_should_behave_like 'supporting Float'
8
+ it_should_behave_like 'supporting Float autocasting'
9
9
  end
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/integer_spec'
4
+ require 'data_objects/spec/shared/typecast/integer_spec'
5
5
 
6
6
  describe 'DataObjects::Mysql with Integer' do
7
- behaves_like 'supporting Integer'
7
+ it_should_behave_like 'supporting Integer'
8
8
  end
@@ -1,10 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/nil_spec'
4
+ require 'data_objects/spec/shared/typecast/nil_spec'
5
5
 
6
6
  describe 'DataObjects::Mysql with Nil' do
7
- behaves_like 'supporting Nil'
8
- behaves_like 'supporting writing an Nil'
9
- behaves_like 'supporting Nil autocasting'
7
+ it_should_behave_like 'supporting Nil'
8
+ it_should_behave_like 'supporting writing an Nil'
9
+ it_should_behave_like 'supporting Nil autocasting'
10
10
  end
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/other_spec'
4
+ require 'data_objects/spec/shared/typecast/other_spec'
5
5
 
6
6
  describe 'DataObjects::H2 with other (unknown) type' do
7
- behaves_like 'supporting other (unknown) type'
7
+ it_should_behave_like 'supporting other (unknown) type'
8
8
  end