do_openedge 0.10.9-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ ## 0.10.9 2012-08-13
2
+
3
+ * First version of do\_openedge
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2012 Abe Voelker, other DataObjects contributors
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,107 @@
1
+ # do_openedge
2
+
3
+ * <http://dataobjects.info>
4
+
5
+ ## Description
6
+
7
+ An OpenEdge driver for DataObjects.
8
+
9
+ ## Features/Problems
10
+
11
+ This driver implements the DataObjects API for the Progress OpenEdge relational database.
12
+ This driver is currently provided only for JRuby.
13
+
14
+ ### Known Issues
15
+
16
+ * `BLOB`/`CLOB` fields cannot be used as predicates or arithmetic/comparison
17
+ operators. In other words, you cannot query rows based on their value. You
18
+ will have to query the rows using a different column value (there is no
19
+ issue doing reads or writes with `BLOB`/`CLOB` fields). See [ProKB P91964][0]
20
+ for more info.
21
+ * The 10.2B JDBC driver causes `DECIMAL`/`NUMERIC` SQL types to round up to the
22
+ nearest integer and then truncate all digits after the decimal point. According
23
+ to [ProKB P187898][1], it appears to be a regression bug in the JDBC driver.
24
+
25
+ ## Synopsis
26
+
27
+ An example of usage:
28
+
29
+ @connection = DataObjects::Connection.new("openedge://localhost:4000/sports2000")
30
+ @reader = @connection.create_command('SELECT * FROM State').execute_reader
31
+ @reader.next!
32
+
33
+ The `Connection` constructor should be passed either a DataObjects-style URI or
34
+ JDBC-style URI:
35
+
36
+ openedge://user:password@host:port/database?option1=value1&option2=value2
37
+ jdbc:datadirect:openedge://host:port/database?user=<value>&password=<value>
38
+
39
+ Note that the DataDirect proprietary-style JDBC URI tokenized with `;`s:
40
+
41
+ jdbc:datadirect:openedge://host:port;databaseName=database;user=<value>;password=<value>
42
+
43
+ is **not** supported.
44
+
45
+ ## Requirements
46
+
47
+ * JRuby 1.3.1 + (1.4+ recommended)
48
+ * `data_objects` gem
49
+ * `do_jdbc` gem (shared library)
50
+
51
+ ## Install
52
+
53
+ To install the gem:
54
+
55
+ jruby -S gem install do_openedge
56
+
57
+ To compile and install from source:
58
+
59
+ * Install the Java Development Kit (provided if you are on a recent version of
60
+ Mac OS X) from <http://java.sun.com>
61
+ * Install a recent version of JRuby. Ensure `jruby` is in your `PATH` and/or
62
+ you have configured the `JRUBY_HOME` environment variable to point to your
63
+ JRuby installation.
64
+ * Install `data_objects` and `do_jdbc` with `jruby -S rake install`.
65
+ * Install this driver with `jruby -S rake install`.
66
+
67
+ ## Developers
68
+
69
+ Follow the above installation instructions. Additionally, you'll need:
70
+ * `rspec` gem for running specs.
71
+ * `YARD` gem for generating documentation.
72
+
73
+ See the DataObjects wiki for more comprehensive information:
74
+ <http://wiki.github.com/datamapper/do/jruby>.
75
+
76
+ To run specs:
77
+
78
+ jruby -S rake spec
79
+
80
+ To run specs without compiling extensions first:
81
+
82
+ jruby -S rake spec_no_compile
83
+
84
+ To run individual specs:
85
+
86
+ jruby -S rake spec SPEC=spec/connection_spec.rb
87
+
88
+ ### Spec data setup
89
+
90
+ The specs require an empty database to use for running tests against
91
+ (the database will be written/read from by the tests). Here are
92
+ some commands to be ran from `proenv` to create an empty
93
+ database that can be used for testing (note the use of UTF-8,
94
+ which is required for proper multibyte string support):
95
+
96
+ prodb test empty
97
+ proutil test -C convchar convert utf-8
98
+ sql_env
99
+ proserve test -S 4000
100
+
101
+ ## License
102
+
103
+ This code is licensed under an **MIT License**. Please see the
104
+ accompanying `LICENSE` file.
105
+
106
+ [0]: http://knowledgebase.progress.com/articles/Article/P91964
107
+ [1]: http://knowledgebase.progress.com/articles/Article/P187898
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ require 'pathname'
2
+ require 'rubygems'
3
+ require 'bundler'
4
+ require 'rubygems/package_task'
5
+ Bundler::GemHelper.install_tasks
6
+
7
+ require 'rake'
8
+ require 'rake/clean'
9
+
10
+ ROOT = Pathname(__FILE__).dirname.expand_path
11
+
12
+ require ROOT + 'lib/do_openedge/version'
13
+
14
+ JRUBY = RUBY_PLATFORM =~ /java/
15
+ IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby'
16
+ WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i)
17
+ SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])
18
+
19
+ CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext-java/target ])
20
+
21
+
22
+ Rake::Task['build'].clear_actions if Rake::Task.task_defined?('build')
23
+ task :build => [ :java, :gem ]
24
+
25
+ FileList['tasks/**/*.rake'].each { |task| import task }
@@ -0,0 +1,29 @@
1
+ require 'data_objects'
2
+
3
+ if RUBY_PLATFORM =~ /java/
4
+ require 'do_jdbc'
5
+ require 'java'
6
+
7
+ module DataObjects
8
+ module Openedge
9
+ JDBC_DRIVER = 'com.ddtek.jdbc.openedge.OpenEdgeDriver'
10
+ end
11
+ end
12
+
13
+ begin
14
+ java.lang.Thread.currentThread.getContextClassLoader().loadClass(DataObjects::Openedge::JDBC_DRIVER, true)
15
+ rescue java.lang.ClassNotFoundException
16
+ # Load the JDBC driver
17
+ require 'jdbc/openedge' # the JDBC driver requires, packaged as a gem
18
+ end
19
+
20
+ require 'do_openedge/do_openedge' # the Java extension for this DO driver
21
+
22
+ # Another way of loading the JDBC Class. This seems to be more reliable
23
+ # than Class.forName() within the data_objects.Connection Java class,
24
+ # which is currently not working as expected.
25
+ java_import DataObjects::Openedge::JDBC_DRIVER
26
+
27
+ else
28
+ warn "do_openedge is only for use with JRuby"
29
+ end
Binary file
@@ -0,0 +1,5 @@
1
+ module DataObjects
2
+ module Openedge
3
+ VERSION = '0.10.9'
4
+ end
5
+ 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/shared/command_spec'
5
+
6
+ describe DataObjects::Openedge::Command do
7
+ it_should_behave_like 'a Command'
8
+ # it_should_behave_like 'a Command with async'
9
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
4
+ require 'data_objects/spec/shared/connection_spec'
5
+
6
+ describe DataObjects::Openedge::Connection do
7
+
8
+ before :all do
9
+ @driver = CONFIG.scheme
10
+ @user = CONFIG.user
11
+ @password = CONFIG.pass
12
+ @host = CONFIG.host
13
+ @port = CONFIG.port
14
+ #TODO
15
+ #@service = CONFIG.service
16
+ @database = CONFIG.database
17
+ end
18
+
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'
22
+ #it_should_behave_like 'a Connection via JDNI'
23
+ 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/shared/encoding_spec'
5
+
6
+ describe DataObjects::Openedge::Connection do
7
+ # it_should_behave_like 'a driver supporting different encodings'
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/shared/reader_spec'
5
+
6
+ describe DataObjects::Openedge::Reader do
7
+ it_should_behave_like 'a Reader'
8
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
4
+ require 'data_objects/spec/shared/result_spec'
5
+
6
+ # splitting the descibe into two separate declaration avoids
7
+ # concurrent execution of the "it_should_behave_like ....."
8
+ # needed by some databases (sqlite3)
9
+
10
+ describe DataObjects::Openedge::Result do
11
+ it_should_behave_like 'a Result'
12
+ end
13
+
14
+ describe DataObjects::Openedge::Result do
15
+ it_should_behave_like 'a Result which returns inserted key with sequences'
16
+ end
@@ -0,0 +1,261 @@
1
+ $TESTING=true
2
+ JRUBY = true
3
+
4
+ require 'rubygems'
5
+ require 'rspec'
6
+ require 'date'
7
+ require 'ostruct'
8
+ require 'fileutils'
9
+
10
+ driver_lib = File.expand_path('../../lib', __FILE__)
11
+ $LOAD_PATH.unshift(driver_lib) unless $LOAD_PATH.include?(driver_lib)
12
+
13
+ # Prepend data_objects/do_jdbc in the repository to the load path.
14
+ # DO NOT USE installed gems, except when running the specs from gem.
15
+ repo_root = File.expand_path('../../..', __FILE__)
16
+ ['data_objects', 'do_jdbc'].each do |lib|
17
+ lib_path = "#{repo_root}/#{lib}/lib"
18
+ $LOAD_PATH.unshift(lib_path) if File.directory?(lib_path) && !$LOAD_PATH.include?(lib_path)
19
+ end
20
+
21
+ require 'data_objects'
22
+ require 'data_objects/spec/setup'
23
+ require 'data_objects/spec/lib/pending_helpers'
24
+ require 'do_openedge'
25
+
26
+ DataObjects::Openedge.logger = DataObjects::Logger.new(STDOUT, :off)
27
+ at_exit { DataObjects.logger.flush }
28
+
29
+
30
+ CONFIG = OpenStruct.new
31
+ CONFIG.scheme = 'openedge'
32
+ CONFIG.driver = 'openedge'
33
+ CONFIG.jdbc_driver = DataObjects::Openedge.const_get('JDBC_DRIVER') rescue nil
34
+ CONFIG.user = ENV['DO_OPENEDGE_USER'] || 'test'
35
+ CONFIG.pass = ENV['DO_OPENEDGE_PASS'] || ''
36
+ CONFIG.host = ENV['DO_OPENEDGE_HOST'] || '192.168.1.241'
37
+ CONFIG.port = ENV['DO_OPENEDGE_PORT'] || '13370'
38
+ CONFIG.database = ENV['DO_OPENEDGE_DATABASE'] || 'test'
39
+ # Result of this query must be a value of "1":
40
+ CONFIG.testsql = "SELECT SIGN(1) FROM SYSPROGRESS.SYSCALCTABLE"
41
+ CONFIG.uri = ENV["DO_OPENEDGE_SPEC_URI"] ||"#{CONFIG.scheme}://#{CONFIG.user}:#{CONFIG.pass}@#{CONFIG.host}:#{CONFIG.port}/#{CONFIG.database}"
42
+ CONFIG.jdbc_uri = "jdbc:openedge://#{CONFIG.host}:#{CONFIG.port}/#{CONFIG.database}?user=#{CONFIG.user}&password=#{CONFIG.pass}"
43
+
44
+ module DataObjectsSpecHelpers
45
+
46
+ TABLE_NOT_FOUND_CODE = -20005
47
+ SEQUENCE_NOT_FOUND_CODE = -210051
48
+ SEQUENCE_NOT_VALID_CODE = -20170
49
+ TRIGGER_NOT_FOUND_CODE = -20147
50
+
51
+ def drop_table_seq_and_trig(conn, table_name, catalog="pub")
52
+ table_name = "#{catalog}.#{table_name}" if catalog && !catalog.empty?
53
+ begin
54
+ conn.create_command("DROP TABLE #{table_name}").execute_non_query
55
+ rescue DataObjects::SQLError => e
56
+ # OpenEdge does not support DROP TABLE IF EXISTS
57
+ raise e unless e.code == TABLE_NOT_FOUND_CODE
58
+ end
59
+
60
+ begin
61
+ conn.create_command("DROP SEQUENCE #{table_name}_id_seq").execute_non_query
62
+ rescue DataObjects::SQLError => e
63
+ raise e unless [SEQUENCE_NOT_FOUND_CODE, SEQUENCE_NOT_VALID_CODE].include?(e.code)
64
+ end
65
+
66
+ begin
67
+ conn.create_command("DROP TRIGGER #{table_name}_trigger").execute_non_query
68
+ rescue DataObjects::SQLError => e
69
+ raise e unless e.code == TRIGGER_NOT_FOUND_CODE
70
+ end
71
+ end
72
+
73
+ def create_seq_and_trigger(conn, table_name, catalog="pub")
74
+ table_name = "#{catalog}.#{table_name}" if catalog && !catalog.empty?
75
+ conn.create_command(<<-EOF).execute_non_query
76
+ CREATE SEQUENCE #{table_name}_id_seq
77
+ START WITH 0,
78
+ INCREMENT BY 1,
79
+ NOCYCLE
80
+ EOF
81
+
82
+ # Not opening up sequence permissions causes weird errors.
83
+ # See ProKB P131308, P10499 for examples
84
+ # Also, GRANT ALL doesn't work on sequences; it raises error 12666 "invalid sequence name"
85
+ # (probably because some table operations don't apply to sequences)
86
+ %w{SELECT UPDATE}.each do |perm|
87
+ conn.create_command(<<-EOF).execute_non_query
88
+ GRANT #{perm} ON SEQUENCE #{table_name}_id_seq TO PUBLIC
89
+ EOF
90
+ end
91
+
92
+ conn.create_command(<<-EOF).execute_non_query
93
+ CREATE TRIGGER #{table_name}_trigger
94
+ BEFORE INSERT ON #{table_name}
95
+ REFERENCING NEWROW
96
+ FOR EACH ROW
97
+ IMPORT
98
+ import java.sql.*;
99
+ BEGIN
100
+ Long current_id = (Long)NEWROW.getValue(1, BIGINT);
101
+ if (current_id == -1) {
102
+ SQLCursor next_id_query = new SQLCursor("SELECT TOP 1 #{table_name}_id_seq.NEXTVAL FROM SYSPROGRESS.SYSCALCTABLE");
103
+ next_id_query.open();
104
+ next_id_query.fetch();
105
+ Long next_id = (Long)next_id_query.getValue(1,BIGINT);
106
+ next_id_query.close();
107
+ NEWROW.setValue(1, next_id);
108
+ }
109
+ END
110
+ EOF
111
+ end
112
+
113
+ def setup_test_environment
114
+ conn = DataObjects::Connection.new(CONFIG.uri)
115
+
116
+ drop_table_seq_and_trig(conn, "invoices")
117
+ drop_table_seq_and_trig(conn, "users")
118
+ drop_table_seq_and_trig(conn, "widgets")
119
+
120
+ # Users
121
+ conn.create_command(<<-EOF).execute_non_query
122
+ CREATE TABLE users (
123
+ id BIGINT PRIMARY KEY DEFAULT -1,
124
+ name VARCHAR(200) default 'Billy',
125
+ fired_at TIMESTAMP
126
+ )
127
+ EOF
128
+ create_seq_and_trigger(conn, "users", "")
129
+
130
+ # Invoices
131
+ conn.create_command(<<-EOF).execute_non_query
132
+ CREATE TABLE invoices (
133
+ id BIGINT PRIMARY KEY DEFAULT -1,
134
+ invoice_number VARCHAR(50) NOT NULL
135
+ )
136
+ EOF
137
+ create_seq_and_trigger(conn, "invoices", "")
138
+
139
+ # Widgets
140
+ conn.create_command(<<-EOF).execute_non_query
141
+ CREATE TABLE widgets (
142
+ id BIGINT PRIMARY KEY DEFAULT -1,
143
+ code CHAR(8) DEFAULT 'A14',
144
+ name VARCHAR(200) DEFAULT 'Super Widget',
145
+ shelf_location VARCHAR(4000),
146
+ description VARCHAR(4000),
147
+ image_data BLOB,
148
+ ad_description VARCHAR(4000),
149
+ ad_image BLOB,
150
+ whitepaper_text CLOB,
151
+ class_name VARCHAR(4000),
152
+ cad_drawing BLOB,
153
+ flags BIT DEFAULT 0,
154
+ number_in_stock SMALLINT DEFAULT 500,
155
+ number_sold INTEGER DEFAULT 0,
156
+ super_number BIGINT DEFAULT 9223372036854775807,
157
+ weight FLOAT DEFAULT 1.23,
158
+ cost1 REAL DEFAULT 10.23,
159
+ cost2 DECIMAL DEFAULT 50.23,
160
+ release_date DATE DEFAULT '2008-02-14',
161
+ release_datetime TIMESTAMP DEFAULT '2008-02-14 00:31:12',
162
+ release_timestamp TIMESTAMP DEFAULT '2008-02-14 00:31:31'
163
+ )
164
+ EOF
165
+ create_seq_and_trigger(conn, "widgets", "")
166
+
167
+ # XXX: OpenEdge has no ENUM
168
+ # status` enum('active','out of stock') NOT NULL default 'active'
169
+
170
+ command = conn.create_command(<<-EOF)
171
+ INSERT INTO widgets(
172
+ code,
173
+ name,
174
+ shelf_location,
175
+ description,
176
+ ad_description,
177
+ class_name,
178
+ super_number,
179
+ weight,
180
+ release_datetime,
181
+ release_timestamp)
182
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
183
+ EOF
184
+
185
+ 1.upto(16) do |n|
186
+ command.execute_non_query(
187
+ "W#{n.to_s.rjust(7,'0')}",
188
+ "Widget #{n}",
189
+ 'A14',
190
+ 'This is a description',
191
+ 'Buy this product now!',
192
+ 'String',
193
+ 1234,
194
+ 13.4,
195
+ Time.local(2008,2,14,0,31,12),
196
+ Time.local(2008,2,14,0,31,12))
197
+ end
198
+
199
+ # These updates are done separately from the initial inserts because the
200
+ # BLOB/CLOB fields seem to stop the before insert trigger from running!
201
+ 1.upto(16) do |i|
202
+ command = conn.create_command(<<-EOF)
203
+ update widgets set
204
+ image_data = ?,
205
+ ad_image = ?,
206
+ whitepaper_text = ?,
207
+ cad_drawing = ?
208
+ where id = #{i}
209
+ EOF
210
+ command.execute_non_query(
211
+ ::Extlib::ByteArray.new('IMAGE DATA'),
212
+ ::Extlib::ByteArray.new('AD IMAGE DATA'),
213
+ '1234567890'*500,
214
+ ::Extlib::ByteArray.new("CAD \001 \000 DRAWING")
215
+ )
216
+ end
217
+
218
+ conn.create_command(<<-EOF).execute_non_query
219
+ update widgets set flags = 1 where id = 2
220
+ EOF
221
+
222
+ conn.create_command(<<-EOF).execute_non_query
223
+ update widgets set ad_description = NULL where id = 3
224
+ EOF
225
+
226
+ conn.create_command(<<-EOF).execute_non_query
227
+ update widgets set flags = NULL where id = 4
228
+ EOF
229
+
230
+ conn.create_command(<<-EOF).execute_non_query
231
+ update widgets set cost1 = NULL where id = 5
232
+ EOF
233
+
234
+ conn.create_command(<<-EOF).execute_non_query
235
+ update widgets set cost2 = NULL where id = 6
236
+ EOF
237
+
238
+ conn.create_command(<<-EOF).execute_non_query
239
+ update widgets set release_date = NULL where id = 7
240
+ EOF
241
+
242
+ conn.create_command(<<-EOF).execute_non_query
243
+ update widgets set release_datetime = NULL where id = 8
244
+ EOF
245
+
246
+ conn.create_command(<<-EOF).execute_non_query
247
+ update widgets set release_timestamp = NULL where id = 9
248
+ EOF
249
+
250
+ conn.create_command(<<-EOF).execute_non_query
251
+ update widgets set release_datetime = '2008-07-14 00:31:12' where id = 10
252
+ EOF
253
+
254
+ conn.close
255
+ end
256
+ end
257
+
258
+ RSpec.configure do |config|
259
+ config.include(DataObjectsSpecHelpers)
260
+ config.include(DataObjects::Spec::PendingHelpers)
261
+ 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/shared/typecast/array_spec'
5
+
6
+ describe 'DataObjects::Openedge with Array' do
7
+ it_should_behave_like 'supporting Array'
8
+ end
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/shared/typecast/bigdecimal_spec'
5
+
6
+ describe 'DataObjects::Openedge with BigDecimal' do
7
+ it_should_behave_like 'supporting BigDecimal'
8
+ #it_should_behave_like 'supporting BigDecimal autocasting'
9
+ end
10
+
11
+ describe 'supporting BigDecimal autocasting' do
12
+
13
+ before :all do
14
+ setup_test_environment
15
+ end
16
+
17
+ before do
18
+ @connection = DataObjects::Connection.new(CONFIG.uri)
19
+ end
20
+
21
+ after do
22
+ @connection.close
23
+ end
24
+
25
+ describe 'reading a BigDecimal' do
26
+
27
+ describe 'with automatic typecasting' do
28
+
29
+ before do
30
+ @reader = @connection.create_command("SELECT cost2 FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
31
+ @reader.next!
32
+ @values = @reader.values
33
+ end
34
+
35
+ after do
36
+ @reader.close
37
+ end
38
+
39
+ it 'should return the correctly typed result' do
40
+ @values.first.should be_kind_of(BigDecimal)
41
+ end
42
+
43
+ # There is an error in the JDBC driver that truncates these results. See ProKB P187898:
44
+ # http://knowledgebase.progress.com/articles/Article/P187898
45
+ =begin
46
+ it 'should return the correct result' do
47
+ @values.first.should == 50.23
48
+ end
49
+ =end
50
+ end
51
+
52
+ end
53
+
54
+ 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/shared/typecast/boolean_spec'
5
+
6
+ describe 'DataObjects::Openedge with Boolean' do
7
+ it_should_behave_like 'supporting Boolean'
8
+ it_should_behave_like 'supporting Boolean autocasting'
9
+ end
@@ -0,0 +1,96 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+
5
+ # Can't use full shared spec due to ProKB P91964
6
+ #require 'data_objects/spec/shared/typecast/byte_array_spec'
7
+
8
+ describe 'supporting ByteArray' do
9
+
10
+ before :all do
11
+ setup_test_environment
12
+ end
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 ByteArray' do
23
+
24
+ describe 'with automatic typecasting' do
25
+
26
+ before do
27
+ @reader = @connection.create_command("SELECT cad_drawing 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(::Extlib::ByteArray)
38
+ end
39
+
40
+ it 'should return the correct result' do
41
+ @values.first.should == "CAD \001 \000 DRAWING"
42
+ end
43
+
44
+ end
45
+
46
+ describe 'with manual typecasting' do
47
+
48
+ before do
49
+ @command = @connection.create_command("SELECT cad_drawing FROM widgets WHERE ad_description = ?")
50
+ @command.set_types(::Extlib::ByteArray)
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(::Extlib::ByteArray)
62
+ end
63
+
64
+ it 'should return the correct result' do
65
+ @values.first.should == "CAD \001 \000 DRAWING"
66
+ end
67
+
68
+ end
69
+
70
+ end
71
+
72
+ # CLOB/BLOB fields cannot be used in a query predicate. See ProKB P91964:
73
+ # http://knowledgebase.progress.com/articles/Article/P91964
74
+
75
+ =begin
76
+ describe 'writing a ByteArray' do
77
+
78
+ before do
79
+ @reader = @connection.create_command("SELECT ad_description FROM widgets WHERE cad_drawing = ?").execute_reader(::Extlib::ByteArray.new("CAD \001 \000 DRAWING"))
80
+ @reader.next!
81
+ @values = @reader.values
82
+ end
83
+
84
+ after do
85
+ @reader.close
86
+ end
87
+
88
+ it 'should return the correct entry' do
89
+ #Some of the drivers starts autoincrementation from 0 not 1
90
+ @values.first.should == 'Buy this product now!'
91
+ end
92
+
93
+ end
94
+ =end
95
+
96
+ end
@@ -0,0 +1,68 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/shared/typecast/class_spec'
5
+
6
+ describe 'DataObjects::Openedge with Class' do
7
+
8
+ include DataObjectsSpecHelpers
9
+
10
+ before :all do
11
+ setup_test_environment
12
+ end
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 Class' do
23
+
24
+ describe 'with manual typecasting' do
25
+
26
+ before do
27
+ @command = @connection.create_command("SELECT class_name FROM widgets WHERE ad_description = ?")
28
+ @command.set_types(Class)
29
+ @reader = @command.execute_reader('Buy this product now!')
30
+ @reader.next!
31
+ @values = @reader.values
32
+ end
33
+
34
+ after do
35
+ @reader.close
36
+ end
37
+
38
+ it 'should return the correctly typed result' do
39
+ @values.first.should be_kind_of(Class)
40
+ end
41
+
42
+ it 'should return the correct result' do
43
+ @values.first.should == String
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+
50
+ describe 'writing a Class' do
51
+
52
+ before do
53
+ @reader = @connection.create_command("SELECT class_name FROM widgets WHERE class_name = ?").execute_reader(String)
54
+ @reader.next!
55
+ @values = @reader.values
56
+ end
57
+
58
+ after do
59
+ @reader.close
60
+ end
61
+
62
+ it 'should return the correct entry' do
63
+ @values.first.should == "String"
64
+ end
65
+
66
+ end
67
+
68
+ 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/shared/typecast/date_spec'
5
+
6
+ describe 'DataObjects::Openedge with Date' do
7
+ it_should_behave_like 'supporting Date'
8
+ it_should_behave_like 'supporting Date autocasting'
9
+ 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/shared/typecast/datetime_spec'
5
+
6
+ describe 'DataObjects::Openedge with DateTime' do
7
+ it_should_behave_like 'supporting DateTime'
8
+ it_should_behave_like 'supporting DateTime autocasting'
9
+ 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/shared/typecast/float_spec'
5
+
6
+ describe 'DataObjects::Openedge with Float' do
7
+ it_should_behave_like 'supporting Float'
8
+ it_should_behave_like 'supporting Float autocasting'
9
+ 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/shared/typecast/integer_spec'
5
+
6
+ describe 'DataObjects::Openedge with Integer' do
7
+ it_should_behave_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/shared/typecast/nil_spec'
5
+
6
+ describe 'DataObjects::Openedge with Nil' do
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
+ 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/shared/typecast/other_spec'
5
+
6
+ describe 'DataObjects::Openedge with other (unknown) type' do
7
+ it_should_behave_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/shared/typecast/range_spec'
5
+
6
+ describe 'DataObjects::Openedge with Range' do
7
+ it_should_behave_like 'supporting Range'
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/shared/typecast/string_spec'
5
+
6
+ describe 'DataObjects::Openedge with String' do
7
+ it_should_behave_like 'supporting String'
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/shared/typecast/time_spec'
5
+
6
+ describe 'DataObjects::Openedge with Time' do
7
+ it_should_behave_like 'supporting Time'
8
+ end
@@ -0,0 +1,30 @@
1
+ begin
2
+ gem 'rake-compiler', '~>0.7'
3
+ require 'rake/javaextensiontask'
4
+
5
+ def gemspec
6
+ @clean_gemspec ||= Gem::Specification::load(File.expand_path('../../do_openedge.gemspec', __FILE__))
7
+ end
8
+
9
+ Rake::JavaExtensionTask.new('do_openedge', gemspec) do |ext|
10
+ ext.ext_dir = 'ext-java/src/main/java'
11
+ ext.lib_dir = "lib/#{gemspec.name}"
12
+ ext.debug = ENV.has_key?('DO_JAVA_DEBUG') && ENV['DO_JAVA_DEBUG']
13
+ ext.classpath = '../do_jdbc/lib/do_jdbc_internal.jar'
14
+ ext.java_compiling do |gem|
15
+ gem.add_dependency 'jdbc-openedge'
16
+ gem.add_dependency 'do_jdbc', '0.10.9'
17
+ end
18
+ end
19
+
20
+ # do_openedge is only available for JRuby: the normal behaviour of rake-compiler
21
+ # is to only chain 'compile:PLATFORM' tasks to 'compile' where PLATFORM is the
22
+ # platform of the current interpreter (i.e. 'compile:java' to 'compile' only
23
+ # if running on JRuby). However, we always want to compile for Java, even if
24
+ # running from MRI.
25
+ task 'compile:do_openedge' => ['compile:do_openedge:java']
26
+ task 'compile' => ['compile:java']
27
+
28
+ rescue LoadError
29
+ warn "To compile, install rake-compiler (gem install rake-compiler)"
30
+ end
@@ -0,0 +1,14 @@
1
+ desc 'Builds all gems (native, binaries for JRuby and Windows)'
2
+ task :build_all do
3
+ `rake clean`
4
+ `rake java gem`
5
+ end
6
+
7
+ desc 'Release all gems (native, binaries for JRuby and Windows)'
8
+ task :release_all => :build_all do
9
+ Dir["pkg/do_openedge-#{DataObjects::Openedge::VERSION}*.gem"].each do |gem_path|
10
+ command = "gem push #{gem_path}"
11
+ puts "Executing #{command.inspect}:"
12
+ sh command
13
+ end
14
+ end
data/tasks/spec.rake ADDED
@@ -0,0 +1,11 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:spec => [:clean, :compile]) do |spec|
4
+ spec.pattern = './spec/**/*_spec.rb'
5
+ end
6
+
7
+ RSpec::Core::RakeTask.new(:rcov => [:clean, :compile]) do |rcov|
8
+ rcov.pattern = "./spec/**/*_spec.rb"
9
+ rcov.rcov = true
10
+ rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/)
11
+ end
metadata ADDED
@@ -0,0 +1,191 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: do_openedge
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 10
8
+ - 9
9
+ version: 0.10.9
10
+ platform: java
11
+ authors:
12
+ - Abe Voelker
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2012-06-05 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ prerelease: false
22
+ type: :runtime
23
+ name: data_objects
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ - 10
31
+ - 9
32
+ version: 0.10.9
33
+ requirement: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ prerelease: false
36
+ type: :runtime
37
+ name: do_jdbc
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "="
41
+ - !ruby/object:Gem::Version
42
+ segments:
43
+ - 0
44
+ - 10
45
+ - 9
46
+ version: 0.10.9
47
+ requirement: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ prerelease: false
50
+ type: :development
51
+ name: rspec
52
+ version_requirements: &id003 !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 2
58
+ - 5
59
+ version: "2.5"
60
+ requirement: *id003
61
+ - !ruby/object:Gem::Dependency
62
+ prerelease: false
63
+ type: :development
64
+ name: rake-compiler
65
+ version_requirements: &id004 !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ - 7
72
+ version: "0.7"
73
+ requirement: *id004
74
+ - !ruby/object:Gem::Dependency
75
+ prerelease: false
76
+ type: :runtime
77
+ name: jdbc-openedge
78
+ version_requirements: &id005 !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
84
+ version: "0"
85
+ requirement: *id005
86
+ - !ruby/object:Gem::Dependency
87
+ prerelease: false
88
+ type: :runtime
89
+ name: do_jdbc
90
+ version_requirements: &id006 !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "="
93
+ - !ruby/object:Gem::Version
94
+ segments:
95
+ - 0
96
+ - 10
97
+ - 9
98
+ version: 0.10.9
99
+ requirement: *id006
100
+ description: Implements the DataObjects API for OpenEdge
101
+ email: abe@abevoelker.com
102
+ executables: []
103
+
104
+ extensions: []
105
+
106
+ extra_rdoc_files:
107
+ - ChangeLog.markdown
108
+ - LICENSE
109
+ - README.markdown
110
+ files:
111
+ - ChangeLog.markdown
112
+ - LICENSE
113
+ - README.markdown
114
+ - Rakefile
115
+ - lib/do_openedge.rb
116
+ - lib/do_openedge/version.rb
117
+ - spec/command_spec.rb
118
+ - spec/connection_spec.rb
119
+ - spec/encoding_spec.rb
120
+ - spec/reader_spec.rb
121
+ - spec/result_spec.rb
122
+ - spec/spec_helper.rb
123
+ - spec/typecast/array_spec.rb
124
+ - spec/typecast/bigdecimal_spec.rb
125
+ - spec/typecast/boolean_spec.rb
126
+ - spec/typecast/byte_array_spec.rb
127
+ - spec/typecast/class_spec.rb
128
+ - spec/typecast/date_spec.rb
129
+ - spec/typecast/datetime_spec.rb
130
+ - spec/typecast/float_spec.rb
131
+ - spec/typecast/integer_spec.rb
132
+ - spec/typecast/nil_spec.rb
133
+ - spec/typecast/other_spec.rb
134
+ - spec/typecast/range_spec.rb
135
+ - spec/typecast/string_spec.rb
136
+ - spec/typecast/time_spec.rb
137
+ - tasks/compile.rake
138
+ - tasks/release.rake
139
+ - tasks/spec.rake
140
+ - lib/do_openedge/do_openedge.jar
141
+ has_rdoc: true
142
+ homepage:
143
+ licenses: []
144
+
145
+ post_install_message:
146
+ rdoc_options: []
147
+
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ segments:
155
+ - 0
156
+ version: "0"
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ segments:
162
+ - 0
163
+ version: "0"
164
+ requirements: []
165
+
166
+ rubyforge_project: dorb
167
+ rubygems_version: 1.3.6
168
+ signing_key:
169
+ specification_version: 3
170
+ summary: DataObjects OpenEdge Driver
171
+ test_files:
172
+ - spec/command_spec.rb
173
+ - spec/connection_spec.rb
174
+ - spec/encoding_spec.rb
175
+ - spec/reader_spec.rb
176
+ - spec/result_spec.rb
177
+ - spec/spec_helper.rb
178
+ - spec/typecast/array_spec.rb
179
+ - spec/typecast/bigdecimal_spec.rb
180
+ - spec/typecast/boolean_spec.rb
181
+ - spec/typecast/byte_array_spec.rb
182
+ - spec/typecast/class_spec.rb
183
+ - spec/typecast/date_spec.rb
184
+ - spec/typecast/datetime_spec.rb
185
+ - spec/typecast/float_spec.rb
186
+ - spec/typecast/integer_spec.rb
187
+ - spec/typecast/nil_spec.rb
188
+ - spec/typecast/other_spec.rb
189
+ - spec/typecast/range_spec.rb
190
+ - spec/typecast/string_spec.rb
191
+ - spec/typecast/time_spec.rb