do_oracle 0.10.1-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,89 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/byte_array_spec'
5
+
6
+ describe 'DataObjects::Oracle with ByteArray' do
7
+
8
+ setup_test_environment
9
+
10
+ before do
11
+ @connection = DataObjects::Connection.new(CONFIG.uri)
12
+ end
13
+
14
+ after do
15
+ @connection.close
16
+ end
17
+
18
+ describe 'reading a ByteArray' do
19
+
20
+ describe 'with automatic typecasting' do
21
+
22
+ before do
23
+ @reader = @connection.create_command("SELECT cad_drawing FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
24
+ @reader.next!
25
+ @values = @reader.values
26
+ end
27
+
28
+ after do
29
+ @reader.close
30
+ end
31
+
32
+ it 'should return the correctly typed result' do
33
+ @values.first.should.be.kind_of(::Extlib::ByteArray)
34
+ end
35
+
36
+ it 'should return the correct result' do
37
+ @values.first.should == "CAD \001 \000 DRAWING"
38
+ end
39
+
40
+ end
41
+
42
+ describe 'with manual typecasting' do
43
+
44
+ before do
45
+ @command = @connection.create_command("SELECT cad_drawing FROM widgets WHERE ad_description = ?")
46
+ @command.set_types(::Extlib::ByteArray)
47
+ @reader = @command.execute_reader('Buy this product now!')
48
+ @reader.next!
49
+ @values = @reader.values
50
+ end
51
+
52
+ after do
53
+ @reader.close
54
+ end
55
+
56
+ it 'should return the correctly typed result' do
57
+ @values.first.should.be.kind_of(::Extlib::ByteArray)
58
+ end
59
+
60
+ it 'should return the correct result' do
61
+ @values.first.should == "CAD \001 \000 DRAWING"
62
+ end
63
+
64
+ end
65
+
66
+ end
67
+
68
+ describe 'inserting a large binary value' do
69
+
70
+ before do
71
+ @binary_value = ::Extlib::ByteArray.new("\000\001\002\003\004"*1000)
72
+ @result = @connection.create_command("INSERT INTO widgets (cad_drawing) VALUES (?) RETURNING id INTO :insert_id").
73
+ execute_non_query(@binary_value)
74
+ @reader = @connection.create_command("SELECT cad_drawing FROM widgets WHERE id = ?").execute_reader(@result.insert_id)
75
+ @reader.next!
76
+ @values = @reader.values
77
+ end
78
+
79
+ after do
80
+ @reader.close
81
+ end
82
+
83
+ it 'should return the correct entry' do
84
+ @values.first.should == @binary_value
85
+ end
86
+
87
+ end
88
+
89
+ end
@@ -0,0 +1,64 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/class_spec'
5
+
6
+ describe 'DataObjects::Oracle with Class' do
7
+
8
+ setup_test_environment
9
+
10
+ before do
11
+ @connection = DataObjects::Connection.new(CONFIG.uri)
12
+ end
13
+
14
+ after do
15
+ @connection.close
16
+ end
17
+
18
+ describe 'reading a Class' do
19
+
20
+ describe 'with manual typecasting' do
21
+
22
+ before do
23
+ @command = @connection.create_command("SELECT class_name FROM widgets WHERE ad_description = ?")
24
+ @command.set_types(Class)
25
+ @reader = @command.execute_reader('Buy this product now!')
26
+ @reader.next!
27
+ @values = @reader.values
28
+ end
29
+
30
+ after do
31
+ @reader.close
32
+ end
33
+
34
+ it 'should return the correctly typed result' do
35
+ @values.first.should.be.kind_of(Class)
36
+ end
37
+
38
+ it 'should return the correct result' do
39
+ @values.first.should == String
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+
46
+ describe 'writing a Class' do
47
+
48
+ before do
49
+ @reader = @connection.create_command("SELECT class_name FROM widgets WHERE class_name = ?").execute_reader(String)
50
+ @reader.next!
51
+ @values = @reader.values
52
+ end
53
+
54
+ after do
55
+ @reader.close
56
+ end
57
+
58
+ it 'should return the correct entry' do
59
+ @values.first.should == "String"
60
+ end
61
+
62
+ end
63
+
64
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/date_spec'
5
+
6
+ describe 'DataObjects::Oracle with Date' do
7
+ behaves_like 'supporting Date'
8
+
9
+ # Oracle will cast DATE type to Time
10
+ # behaves_like 'supporting Date autocasting'
11
+ end
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/datetime_spec'
5
+
6
+ describe 'DataObjects::Oracle with DateTime' do
7
+ behaves_like 'supporting DateTime'
8
+ # behaves_like 'supporting DateTime autocasting'
9
+ end
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/float_spec'
5
+
6
+ describe 'DataObjects::Oracle with Float' do
7
+ behaves_like 'supporting Float'
8
+ # behaves_like 'supporting Float autocasting'
9
+ end
10
+
11
+ describe 'DataObjects::Oracle with Float supporting Float autocasting' do
12
+
13
+ setup_test_environment
14
+
15
+ before do
16
+ @connection = DataObjects::Connection.new(CONFIG.uri)
17
+ end
18
+
19
+ after do
20
+ @connection.close
21
+ end
22
+
23
+ describe 'reading a Float' do
24
+
25
+ describe 'with automatic typecasting' do
26
+
27
+ before do
28
+ @reader = @connection.create_command("SELECT weight, cost1 FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
29
+ @reader.next!
30
+ @values = @reader.values
31
+ end
32
+
33
+ after do
34
+ @reader.close
35
+ end
36
+
37
+ it 'should return the correctly typed result' do
38
+ @values.first.should.be.kind_of(Float)
39
+ @values.last.should.be.kind_of(Float)
40
+ end
41
+
42
+ it 'should return the correct result' do
43
+ @values.first.should.be.close(13.4, 0.000001)
44
+ @values.last.should.be.close(10.23, 0.000001)
45
+ end
46
+
47
+ end
48
+
49
+ end
50
+
51
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/integer_spec'
5
+
6
+ describe 'DataObjects::Oracle with Integer' do
7
+ behaves_like 'supporting Integer'
8
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/nil_spec'
5
+
6
+ describe 'DataObjects::Oracle with Nil' do
7
+ behaves_like 'supporting Nil'
8
+ behaves_like 'supporting writing an Nil'
9
+ behaves_like 'supporting Nil autocasting'
10
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/other_spec'
5
+
6
+ describe 'DataObjects::H2 with other (unknown) type' do
7
+ behaves_like 'supporting other (unknown) type'
8
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/range_spec'
5
+
6
+ describe 'DataObjects::Oracle with Range' do
7
+ behaves_like 'supporting Range'
8
+ end
@@ -0,0 +1,170 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/string_spec'
5
+
6
+ # describe 'DataObjects::Oracle with String' do
7
+ # behaves_like 'supporting String'
8
+ # end
9
+
10
+ describe 'DataObjects::Oracle with String' do
11
+
12
+ setup_test_environment
13
+
14
+ before do
15
+ @connection = DataObjects::Connection.new(CONFIG.uri)
16
+ end
17
+
18
+ after do
19
+ @connection.close
20
+ end
21
+
22
+ describe 'reading a String' do
23
+
24
+ describe 'with automatic typecasting' do
25
+
26
+ before do
27
+ @reader = @connection.create_command("SELECT code FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
28
+ @reader.next!
29
+ @values = @reader.values
30
+ end
31
+
32
+ after do
33
+ @reader.close
34
+ end
35
+
36
+ it 'should return the correctly typed result' do
37
+ @values.first.should.be.kind_of(String)
38
+ end
39
+
40
+ it 'should return the correct result' do
41
+ @values.first.should == "W0000001"
42
+ end
43
+
44
+ end
45
+
46
+ describe 'with manual typecasting' do
47
+
48
+ before do
49
+ @command = @connection.create_command("SELECT weight FROM widgets WHERE ad_description = ?")
50
+ @command.set_types(String)
51
+ @reader = @command.execute_reader('Buy this product now!')
52
+ @reader.next!
53
+ @values = @reader.values
54
+ end
55
+
56
+ after do
57
+ @reader.close
58
+ end
59
+
60
+ it 'should return the correctly typed result' do
61
+ @values.first.should.be.kind_of(String)
62
+ end
63
+
64
+ it 'should return the correct result' do
65
+ @values.first.to_f.should.be.close(13.4, 0.000001)
66
+ end
67
+
68
+ end
69
+
70
+ end
71
+
72
+ describe 'writing a String' do
73
+
74
+ before do
75
+ @reader = @connection.create_command("SELECT id FROM widgets WHERE id = ?").execute_reader("2")
76
+ @reader.next!
77
+ @values = @reader.values
78
+ end
79
+
80
+ after do
81
+ @reader.close
82
+ end
83
+
84
+ it 'should return the correct entry' do
85
+ # Some of the drivers starts autoincrementation from 0 not 1
86
+ @values.first.should.satisfy { |val| val == 1 or val == 2 }
87
+ end
88
+
89
+ end
90
+
91
+ end
92
+
93
+ describe 'DataObjects::Oracle with Text' do
94
+
95
+ setup_test_environment
96
+
97
+ before do
98
+ @connection = DataObjects::Connection.new(CONFIG.uri)
99
+ end
100
+
101
+ after do
102
+ @connection.close
103
+ end
104
+
105
+ describe 'reading a Text' do
106
+
107
+ describe 'with automatic typecasting' do
108
+
109
+ before do
110
+ @reader = @connection.create_command("SELECT whitepaper_text FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
111
+ @reader.next!
112
+ @values = @reader.values
113
+ end
114
+
115
+ after do
116
+ @reader.close
117
+ end
118
+
119
+ it 'should return the correctly typed result' do
120
+ @values.first.should.be.kind_of(String)
121
+ end
122
+
123
+ it 'should return the correct result' do
124
+ @values.first.should == "1234567890"*500
125
+ end
126
+
127
+ end
128
+
129
+ end
130
+
131
+ describe 'inserting a short string to Text column' do
132
+
133
+ before do
134
+ @result = @connection.create_command("INSERT INTO widgets (whitepaper_text) VALUES (?) RETURNING id INTO :insert_id").execute_non_query("short text")
135
+ @reader = @connection.create_command("SELECT whitepaper_text FROM widgets WHERE id = ?").execute_reader(@result.insert_id)
136
+ @reader.next!
137
+ @values = @reader.values
138
+ end
139
+
140
+ after do
141
+ @reader.close
142
+ end
143
+
144
+ it 'should return the correct entry' do
145
+ @values.first.should == "short text"
146
+ end
147
+
148
+ end
149
+
150
+ describe 'inserting a large text to Text column' do
151
+
152
+ before do
153
+ @result = @connection.create_command("INSERT INTO widgets (whitepaper_text) VALUES (?) RETURNING id INTO :insert_id").
154
+ execute_non_query("long text"*1000)
155
+ @reader = @connection.create_command("SELECT whitepaper_text FROM widgets WHERE id = ?").execute_reader(@result.insert_id)
156
+ @reader.next!
157
+ @values = @reader.values
158
+ end
159
+
160
+ after do
161
+ @reader.close
162
+ end
163
+
164
+ it 'should return the correct entry' do
165
+ @values.first.should == "long text"*1000
166
+ end
167
+
168
+ end
169
+
170
+ end
@@ -0,0 +1,85 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/typecast/time_spec'
5
+
6
+ describe 'DataObjects::Oracle with Time' do
7
+ behaves_like 'supporting Time'
8
+ end
9
+
10
+ describe 'DataObjects::Oracle with Time' do
11
+
12
+ setup_test_environment
13
+
14
+ before do
15
+ @connection = DataObjects::Connection.new(CONFIG.uri)
16
+ end
17
+
18
+ after do
19
+ @connection.close
20
+ end
21
+
22
+ describe 'reading a Time' do
23
+
24
+ describe 'with automatic typecasting' do
25
+
26
+ before do
27
+ @reader = @connection.create_command("SELECT release_datetime FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
28
+ @reader.next!
29
+ @values = @reader.values
30
+ end
31
+
32
+ after do
33
+ @reader.close
34
+ end
35
+
36
+ it 'should return the correctly typed result' do
37
+ @values.first.should.be.kind_of(Time)
38
+ end
39
+
40
+ it 'should return the correct result' do
41
+ @values.first.should == Time.local(2008, 2, 14, 00, 31, 12)
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+
50
+ describe 'DataObjects::Oracle session time zone' do
51
+
52
+ after do
53
+ @connection.close
54
+ end
55
+
56
+ describe 'set from environment' do
57
+
58
+ before do
59
+ pending "set TZ environment shell variable before running this test" unless ENV['TZ']
60
+ @connection = DataObjects::Connection.new(CONFIG.uri)
61
+ end
62
+
63
+ it "should have time zone from environment" do
64
+ @reader = @connection.create_command("SELECT sessiontimezone FROM dual").execute_reader
65
+ @reader.next!
66
+ @reader.values.first.should == ENV['TZ']
67
+ end
68
+
69
+ end
70
+
71
+ describe "set with connection string option" do
72
+
73
+ before do
74
+ @connection = DataObjects::Connection.new(CONFIG.uri+"?time_zone=CET")
75
+ end
76
+
77
+ it "should have time zone from connection option" do
78
+ @reader = @connection.create_command("SELECT sessiontimezone FROM dual").execute_reader
79
+ @reader.next!
80
+ @reader.values.first.should == 'CET'
81
+ end
82
+
83
+ end
84
+
85
+ end
@@ -0,0 +1,42 @@
1
+ begin
2
+ gem 'rake-compiler', '~>0.7'
3
+ require 'rake/extensiontask'
4
+ require 'rake/javaextensiontask'
5
+
6
+ # Hack to avoid "allocator undefined for Proc" issue when unpacking Gems:
7
+ # gemspec provided by Jeweler uses Rake::FileList for files, test_files and
8
+ # extra_rdoc_files, and procs cannot be marshalled.
9
+ def gemspec
10
+ @clean_gemspec ||= eval("#{Rake.application.jeweler.gemspec.to_ruby}") # $SAFE = 3\n
11
+ end
12
+
13
+ Rake::ExtensionTask.new('do_oracle', gemspec) do |ext|
14
+
15
+ ext.lib_dir = "lib/#{gemspec.name}"
16
+
17
+ # automatically add build options to avoid need of manual input
18
+ if RUBY_PLATFORM =~ /mswin|mingw/ then
19
+ else
20
+ ext.cross_compile = true
21
+ ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
22
+ end
23
+
24
+ end
25
+
26
+ Rake::JavaExtensionTask.new('do_oracle', gemspec) do |ext|
27
+ ext.lib_dir = "lib/#{gemspec.name}"
28
+ ext.ext_dir = 'ext-java/src/main/java'
29
+ ext.debug = ENV.has_key?('DO_JAVA_DEBUG') && ENV['DO_JAVA_DEBUG']
30
+ ext.classpath = '../do_jdbc/lib/do_jdbc_internal.jar'
31
+ ext.java_compiling do |gem|
32
+
33
+ # Hack: Unfortunately there is no way to remove a dependency in the
34
+ # Gem::Specification API.
35
+ gem.dependencies.delete_if { |d| d.name == 'ruby-oci8'}
36
+
37
+ gem.add_dependency "do_jdbc", '0.10.1'
38
+ end
39
+ end
40
+ rescue LoadError
41
+ warn "To compile, install rake-compiler (gem install rake-compiler)"
42
+ end
@@ -0,0 +1,16 @@
1
+ desc 'Builds all gems (native, binaries for JRuby and Windows)'
2
+ task :build_all do
3
+ `rake clean`
4
+ `rake build`
5
+ `rake java gem`
6
+ `rake cross native gem RUBY_CC_VERSION=1.8.6:1.9.1`
7
+ end
8
+
9
+ desc 'Release all gems (native, binaries for JRuby and Windows)'
10
+ task :release_all => :build_all do
11
+ Dir["pkg/do_oracle-#{DataObjects::Oracle::VERSION}*.gem"].each do |gem_path|
12
+ command = "gem push #{gem_path}"
13
+ puts "Executing #{command.inspect}:"
14
+ sh command
15
+ end
16
+ end
@@ -0,0 +1,67 @@
1
+ begin
2
+ gem 'rake-compiler', '~>0.7'
3
+ require 'rake/clean'
4
+ require 'rake/extensioncompiler'
5
+
6
+ # download mysql library and headers
7
+ directory "vendor"
8
+
9
+ # only on Windows or cross platform compilation
10
+ def dlltool(dllname, deffile, libfile)
11
+ # define if we are using GCC or not
12
+ if Rake::ExtensionCompiler.mingw_gcc_executable then
13
+ dir = File.dirname(Rake::ExtensionCompiler.mingw_gcc_executable)
14
+ tool = case RUBY_PLATFORM
15
+ when /mingw/
16
+ File.join(dir, 'dlltool.exe')
17
+ when /linux|darwin/
18
+ File.join(dir, "#{Rake::ExtensionCompiler.mingw_host}-dlltool")
19
+ end
20
+ return "#{tool} --dllname #{dllname} --def #{deffile} --output-lib #{libfile}"
21
+ else
22
+ if RUBY_PLATFORM =~ /mswin/ then
23
+ tool = 'lib.exe'
24
+ else
25
+ fail "Unsupported platform for cross-compilation (please, contribute some patches)."
26
+ end
27
+ return "#{tool} /DEF:#{deffile} /OUT:#{libfile}"
28
+ end
29
+ end
30
+
31
+ # file "vendor/mysql-noinstall-#{BINARY_VERSION}-win32.zip" => ['vendor'] do |t|
32
+ # base_version = BINARY_VERSION.gsub(/\.[0-9]+$/, '')
33
+ # url = "http://mysql.proserve.nl/Downloads/MySQL-#{base_version}/#{File.basename(t.name)}"
34
+ # when_writing "downloading #{t.name}" do
35
+ # cd File.dirname(t.name) do
36
+ # sh "wget -c #{url} || curl -C - -O #{url}"
37
+ # end
38
+ # end
39
+ # end
40
+ #
41
+ # file "vendor/mysql-#{BINARY_VERSION}-win32/include/mysql.h" => ["vendor/mysql-noinstall-#{BINARY_VERSION}-win32.zip"] do |t|
42
+ # full_file = File.expand_path(t.prerequisites.last)
43
+ # when_writing "creating #{t.name}" do
44
+ # cd "vendor" do
45
+ # sh "unzip #{full_file} mysql-#{BINARY_VERSION}-win32/bin/** mysql-#{BINARY_VERSION}-win32/include/** mysql-#{BINARY_VERSION}-win32/lib/**"
46
+ # end
47
+ # # update file timestamp to avoid Rake perform this extraction again.
48
+ # touch t.name
49
+ # end
50
+ # end
51
+
52
+ # # clobber vendored packages
53
+ # CLOBBER.include('vendor')
54
+
55
+ # # vendor:mysql
56
+ # task 'vendor:mysql' => ["vendor/mysql-#{BINARY_VERSION}-win32/include/mysql.h"]
57
+ #
58
+ # # hook into cross compilation vendored mysql dependency
59
+ # if RUBY_PLATFORM =~ /mingw|mswin/ then
60
+ # Rake::Task['compile'].prerequisites.unshift 'vendor:mysql'
61
+ # else
62
+ # if Rake::Task.tasks.map {|t| t.name }.include? 'cross'
63
+ # Rake::Task['cross'].prerequisites.unshift 'vendor:mysql'
64
+ # end
65
+ # end
66
+ rescue LoadError
67
+ end
data/tasks/spec.rake ADDED
@@ -0,0 +1,23 @@
1
+ require 'rake/testtask'
2
+
3
+ spec_defaults = lambda do |spec|
4
+ spec.libs << 'lib' << 'spec'
5
+ spec.pattern = 'spec/**/*_spec.rb'
6
+ spec.verbose = true
7
+ end
8
+
9
+ Rake::TestTask.new(:spec => [ :clean, :compile ], &spec_defaults)
10
+ Rake::TestTask.new(:spec_no_compile, &spec_defaults)
11
+
12
+ begin
13
+ require 'rcov/rcovtask'
14
+ Rcov::RcovTask.new do |spec|
15
+ spec.libs << 'spec'
16
+ spec.pattern = 'spec/**/*_spec.rb'
17
+ spec.verbose = true
18
+ end
19
+ rescue LoadError
20
+ task :rcov do
21
+ abort 'RCov is not available. In order to run rcov, you must: gem install rcov'
22
+ end
23
+ end