Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Merge branch 'abevoelker-add-openedge-adapter'
Browse files Browse the repository at this point in the history
Conflicts:
	data_objects/lib/data_objects/spec/shared/connection_spec.rb
  • Loading branch information
dbussink committed Sep 27, 2012
2 parents 012db27 + 6a8083e commit 55c3b84
Show file tree
Hide file tree
Showing 41 changed files with 1,284 additions and 15 deletions.
4 changes: 4 additions & 0 deletions README.markdown
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ At present the following drivers are available:
<td>SQL Server</td> <td>SQL Server</td>
<td><em>pending</em></td> <td><em>pending</em></td>
<td>x</td></tr> <td>x</td></tr>
<tr>
<td>OpenEdge</td>
<td>-</td>
<td>x</td></tr>
</table> </table>


There is experimental support for [Rubinius][rubinius]. There is experimental support for [Rubinius][rubinius].
Expand Down
25 changes: 10 additions & 15 deletions data_objects/lib/data_objects/spec/shared/connection_spec.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,13 @@
def test_connection(conn)
reader = conn.create_command(CONFIG.testsql || "SELECT 1").execute_reader
reader.next!
result = reader.values[0]
result
ensure
reader.close
conn.close
end

shared_examples_for 'a Connection' do shared_examples_for 'a Connection' do


before :all do before :all do
Expand Down Expand Up @@ -25,11 +35,6 @@
end end


describe 'various connection URIs' do describe 'various connection URIs' do
def test_connection(conn)
reader = conn.create_command(CONFIG.testsql || "SELECT 1").execute_reader
reader.next!
reader.values[0]
end


it 'should open with an uri object' do it 'should open with an uri object' do
uri = DataObjects::URI.new( uri = DataObjects::URI.new(
Expand Down Expand Up @@ -141,16 +146,6 @@ def connecting_with(uri)
end end
end end


def test_connection(conn)
reader = conn.create_command(CONFIG.testsql || "SELECT 1").execute_reader
reader.next!
result = reader.values[0]
result
ensure
reader.close
conn.close
end

shared_examples_for 'a Connection with JDBC URL support' do shared_examples_for 'a Connection with JDBC URL support' do


it 'should work with JDBC URLs' do it 'should work with JDBC URLs' do
Expand Down
3 changes: 3 additions & 0 deletions do_jdbc/src/main/java/data_objects/Command.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ public IRubyObject execute_non_query(IRubyObject[] args) {
// If there is no support, then a custom method can be defined // If there is no support, then a custom method can be defined
// to return a ResultSet with keys // to return a ResultSet with keys
keys = driver.getGeneratedKeys(conn); keys = driver.getGeneratedKeys(conn);
// The OpenEdge driver needs additional information
if (keys == null)
keys = driver.getGeneratedKeys(conn, sqlStatement, sqlText);
} }
} }
if (usePS && keys != null) { if (usePS && keys != null) {
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -560,6 +560,17 @@ public ResultSet getGeneratedKeys(Connection connection) {
return null; return null;
} }


/**
*
* @param connection
* @param ps
* @param sqlText
* @return
*/
public ResultSet getGeneratedKeys(Connection connection, PreparedStatement ps, String sqlText) throws SQLException{
return null;
}

/** /**
* *
* @return * @return
Expand Down
10 changes: 10 additions & 0 deletions do_jdbc/src/main/java/data_objects/drivers/DriverDefinition.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ public void setPreparedStatementParam(PreparedStatement ps,
*/ */
public ResultSet getGeneratedKeys(Connection connection); public ResultSet getGeneratedKeys(Connection connection);


/**
* Same as above, except with extra parameters (needed by the OpenEdge driver)
*
* @param connection
* @param ps
* @param sqlText
* @return
*/
public ResultSet getGeneratedKeys(Connection connection, PreparedStatement ps, String sqlText) throws SQLException;

/** /**
* A default list of properties for a connection for a driver. * A default list of properties for a connection for a driver.
* *
Expand Down
2 changes: 2 additions & 0 deletions do_openedge/.rspec
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,2 @@
--format documentation
--colour
Empty file added do_openedge/ChangeLog.markdown
Empty file.
14 changes: 14 additions & 0 deletions do_openedge/Gemfile
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,14 @@
source :rubygems

path '../'

gemspec

platforms :jruby do
gem 'jdbc-openedge'
gem 'do_jdbc'
end

group :development do # Development dependencies (as in the gemspec)
gem 'rake', '~> 0.8.7'
end
19 changes: 19 additions & 0 deletions do_openedge/LICENSE
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2012 Abe Voelker, other DataObjects contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
107 changes: 107 additions & 0 deletions do_openedge/README.markdown
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,107 @@
# do_openedge

* <http://dataobjects.info>

## Description

An OpenEdge driver for DataObjects.

## Features/Problems

This driver implements the DataObjects API for the Progress OpenEdge relational database.
This driver is currently provided only for JRuby.

### Known Issues

* `BLOB`/`CLOB` fields cannot be used as predicates or arithmetic/comparison
operators. In other words, you cannot query rows based on their value. You
will have to query the rows using a different column value (there is no
issue doing reads or writes with `BLOB`/`CLOB` fields). See [ProKB P91964][0]
for more info.
* The 10.2B JDBC driver causes `DECIMAL`/`NUMERIC` SQL types to round up to the
nearest integer and then truncate all digits after the decimal point. According
to [ProKB P187898][1], it appears to be a regression bug in the JDBC driver.

## Synopsis

An example of usage:

@connection = DataObjects::Connection.new("openedge://localhost:4000/sports2000")
@reader = @connection.create_command('SELECT * FROM State').execute_reader
@reader.next!

The `Connection` constructor should be passed either a DataObjects-style URI or
JDBC-style URI:

openedge://user:password@host:port/database?option1=value1&option2=value2
jdbc:datadirect:openedge://host:port/database?user=<value>&password=<value>

Note that the DataDirect proprietary-style JDBC URI tokenized with `;`s:

jdbc:datadirect:openedge://host:port;databaseName=database;user=<value>;password=<value>

is **not** supported.

## Requirements

* JRuby 1.3.1 + (1.4+ recommended)
* `data_objects` gem
* `do_jdbc` gem (shared library)

## Install

To install the gem:

jruby -S gem install do_openedge

To compile and install from source:

* Install the Java Development Kit (provided if you are on a recent version of
Mac OS X) from <http://java.sun.com>
* Install a recent version of JRuby. Ensure `jruby` is in your `PATH` and/or
you have configured the `JRUBY_HOME` environment variable to point to your
JRuby installation.
* Install `data_objects` and `do_jdbc` with `jruby -S rake install`.
* Install this driver with `jruby -S rake install`.

## Developers

Follow the above installation instructions. Additionally, you'll need:
* `rspec` gem for running specs.
* `YARD` gem for generating documentation.

See the DataObjects wiki for more comprehensive information:
<http://wiki.github.com/datamapper/do/jruby>.

To run specs:

jruby -S rake spec

To run specs without compiling extensions first:

jruby -S rake spec_no_compile

To run individual specs:

jruby -S rake spec SPEC=spec/connection_spec.rb

### Spec data setup

The specs require an empty database to use for running tests against
(the database will be written/read from by the tests). Here are
some commands to be ran from `proenv` to create an empty
database that can be used for testing (note the use of UTF-8,
which is required for proper multibyte string support):

prodb test empty
proutil test -C convchar convert utf-8
sql_env
proserve test -S 4000

## License

This code is licensed under an **MIT License**. Please see the
accompanying `LICENSE` file.

[0]: http://knowledgebase.progress.com/articles/Article/P91964
[1]: http://knowledgebase.progress.com/articles/Article/P187898
25 changes: 25 additions & 0 deletions do_openedge/Rakefile
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'pathname'
require 'rubygems'
require 'bundler'
require 'rubygems/package_task'
Bundler::GemHelper.install_tasks

require 'rake'
require 'rake/clean'

ROOT = Pathname(__FILE__).dirname.expand_path

require ROOT + 'lib/do_openedge/version'

JRUBY = RUBY_PLATFORM =~ /java/
IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby'
WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i)
SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])

CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext-java/target ])


Rake::Task['build'].clear_actions if Rake::Task.task_defined?('build')
task :build => [ :java, :gem ]

FileList['tasks/**/*.rake'].each { |task| import task }
27 changes: 27 additions & 0 deletions do_openedge/buildfile
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,27 @@
# Apache Buildr buildfile for do_openedge
# see http://incubator.apache.org/buildr/ for more information on Apache Buildr
require 'buildr'
require 'pathname'

VERSION_NUMBER = '1.0'
JDBC_SUPPORT = ['data_objects:jdbc:jar:1.0']
TARGET_DIR = 'pkg/classes'
repositories.remote << 'http://www.ibiblio.org/maven2/'

define 'do_openedge' do
project.version = VERSION_NUMBER
project.group = 'data_objects.rb'

manifest['Copyright'] = 'Abe Voelker (C) 2012'

compile.using :target => '1.5', :lint => 'all', :deprecation => 'true'

define 'ext-java' do
package(:jar).clean.include(TARGET_DIR)

jdbc_support_jar = file('../../do_jdbc/lib/do_jdbc_internal.jar')
jdbc_support = artifact('data_objects:jdbc:jar:1.0').from(jdbc_support_jar)

compile.into(TARGET_DIR).with(JDBC_SUPPORT)
end
end
96 changes: 96 additions & 0 deletions do_openedge/do_openedge.gemspec
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,96 @@
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
s.name = %q{do_openedge}
s.version = "0.10.8"
s.platform = %q{java}

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Abe Voelker"]
s.date = %q{2012-06-05}
s.description = %q{Implements the DataObjects API for OpenEdge}
s.email = %q{abe@abevoelker.com}
s.extra_rdoc_files = [
"ChangeLog.markdown",
"LICENSE",
"README.markdown"
]
s.files = [
"ChangeLog.markdown",
"LICENSE",
"README.markdown",
"Rakefile",
"lib/do_openedge.rb",
"lib/do_openedge/version.rb",
"spec/command_spec.rb",
"spec/connection_spec.rb",
"spec/encoding_spec.rb",
"spec/reader_spec.rb",
"spec/result_spec.rb",
"spec/spec_helper.rb",
"spec/typecast/array_spec.rb",
"spec/typecast/bigdecimal_spec.rb",
"spec/typecast/boolean_spec.rb",
"spec/typecast/byte_array_spec.rb",
"spec/typecast/class_spec.rb",
"spec/typecast/date_spec.rb",
"spec/typecast/datetime_spec.rb",
"spec/typecast/float_spec.rb",
"spec/typecast/integer_spec.rb",
"spec/typecast/nil_spec.rb",
"spec/typecast/other_spec.rb",
"spec/typecast/range_spec.rb",
"spec/typecast/string_spec.rb",
"spec/typecast/time_spec.rb",
"tasks/compile.rake",
"tasks/release.rake",
"tasks/spec.rake"
]
s.require_paths = ["lib"]
s.rubyforge_project = %q{dorb}
s.rubygems_version = %q{1.6.2}
s.summary = %q{DataObjects OpenEdge Driver}
s.test_files = [
"spec/command_spec.rb",
"spec/connection_spec.rb",
"spec/encoding_spec.rb",
"spec/reader_spec.rb",
"spec/result_spec.rb",
"spec/spec_helper.rb",
"spec/typecast/array_spec.rb",
"spec/typecast/bigdecimal_spec.rb",
"spec/typecast/boolean_spec.rb",
"spec/typecast/byte_array_spec.rb",
"spec/typecast/class_spec.rb",
"spec/typecast/date_spec.rb",
"spec/typecast/datetime_spec.rb",
"spec/typecast/float_spec.rb",
"spec/typecast/integer_spec.rb",
"spec/typecast/nil_spec.rb",
"spec/typecast/other_spec.rb",
"spec/typecast/range_spec.rb",
"spec/typecast/string_spec.rb",
"spec/typecast/time_spec.rb"
]

if s.respond_to? :specification_version then
s.specification_version = 3

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<data_objects>, ["= 0.10.8"])
s.add_runtime_dependency(%q<do_jdbc>, ["= 0.10.8"])
s.add_development_dependency(%q<rspec>, ["~> 2.5"])
s.add_development_dependency(%q<rake-compiler>, ["~> 0.7"])
else
s.add_dependency(%q<data_objects>, ["= 0.10.8"])
s.add_dependency(%q<do_jdbc>, ["= 0.10.8"])
s.add_dependency(%q<rspec>, ["~> 2.5"])
s.add_dependency(%q<rake-compiler>, ["~> 0.7"])
end
else
s.add_dependency(%q<data_objects>, ["= 0.10.8"])
s.add_dependency(%q<do_jdbc>, ["= 0.10.8"])
s.add_dependency(%q<rspec>, ["~> 2.5"])
s.add_dependency(%q<rake-compiler>, ["~> 0.7"])
end
end
Loading

0 comments on commit 55c3b84

Please sign in to comment.