sequel-jdbc-as400 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.rspec +3 -0
- data/.rubocop.yml +41 -0
- data/.ruby-version +1 -0
- data/.travis.yml +12 -0
- data/Gemfile +2 -0
- data/MIT-LICENSE +19 -0
- data/README.md +25 -0
- data/Rakefile +11 -0
- data/lib/sequel/jdbc/as400.rb +93 -0
- data/lib/sequel/jdbc/as400/version.rb +7 -0
- data/sequel-jdbc-as400.gemspec +25 -0
- metadata +167 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 537734a668a237cd882400f92fe761ac938afbd7
|
4
|
+
data.tar.gz: e473e1cfb9b2be6657d455f408c23c52e56f7a7a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b9111bd38ac66da365fbd1a41f9e56b279cd36cbbe20f9b1a6a04cefa97b5f136ebd04fe26fc32203d4d604691c056d6da000e1ae0e1cb2dfecde2a5db6e52a6
|
7
|
+
data.tar.gz: 1dedd0ba0f0a21b3621e6c883f104bf86c2827e76d6b0ab64670cae3693b0da696fd21957e242bd9224b93da6d1d13e593d10e8bf30e8eea282759b7aeafdef4
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Gemfile.lock
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 1.9
|
3
|
+
DisplayCopNames: true
|
4
|
+
|
5
|
+
Lint/EndAlignment:
|
6
|
+
EnforcedStyleAlignWith: variable
|
7
|
+
|
8
|
+
Metrics/BlockLength:
|
9
|
+
Exclude:
|
10
|
+
- spec/**/*
|
11
|
+
Metrics/LineLength:
|
12
|
+
Max: 132
|
13
|
+
Metrics/MethodLength:
|
14
|
+
Severity: warning
|
15
|
+
|
16
|
+
# Rationale: allow Weirich-style blocks
|
17
|
+
Style/BlockDelimiters:
|
18
|
+
Enabled: false
|
19
|
+
Style/Documentation:
|
20
|
+
Enabled: false
|
21
|
+
Style/Encoding:
|
22
|
+
Enabled: false
|
23
|
+
Style/FileName:
|
24
|
+
Enabled: false
|
25
|
+
Style/FrozenStringLiteralComment:
|
26
|
+
Enabled: false
|
27
|
+
Style/MultilineOperationIndentation:
|
28
|
+
EnforcedStyle: indented
|
29
|
+
Style/NumericPredicate:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
# Default in v0.48.1, but older versions are being used for older Ruby versions, so we set this explicitly here to have the same
|
33
|
+
# settings on all Ruby versions.
|
34
|
+
Style/PercentLiteralDelimiters:
|
35
|
+
PreferredDelimiters:
|
36
|
+
default: ()
|
37
|
+
'%i': '[]'
|
38
|
+
'%I': '[]'
|
39
|
+
'%r': '{}'
|
40
|
+
'%w': '[]'
|
41
|
+
'%W': '[]'
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
jruby-9.1.8.0
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2007-2008 Sharon Rosner
|
2
|
+
Copyright (c) 2008-2017 Jeremy Evans
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to
|
6
|
+
deal in the Software without restriction, including without limitation the
|
7
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
8
|
+
sell copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
12
|
+
all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
17
|
+
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/ecraft/sequel-jdbc-as400.svg?branch=master)](https://travis-ci.org/ecraft/sequel-jdbc-as400)
|
2
|
+
|
3
|
+
# sequel-jdbc-as400
|
4
|
+
|
5
|
+
JDBC AS400 adapter for the [Sequel](https://github.com/jeremyevans/sequel) Ruby gem
|
6
|
+
|
7
|
+
This gem is a fork of the code which used to be a part of the Sequel codebase, but which was removed as of Sequel 5. (unreleased at the time of writing) If your application relies on the as400 adapter, use this gem together with `sequel` to still be able to connect to AS400 databases.
|
8
|
+
|
9
|
+
## Development
|
10
|
+
|
11
|
+
```shell
|
12
|
+
$ bundle install
|
13
|
+
$ CONNECTION_STRING="jdbc:as400://server-name/;prompt=false;user=login;password=pw;libraries=DBNAME;query timeout mechanism=cancel; bundle exec rspec
|
14
|
+
```
|
15
|
+
|
16
|
+
(replace the connection string with a real one, pointing at a AS400 DB2 server.)
|
17
|
+
|
18
|
+
## Releasing a new gem version
|
19
|
+
|
20
|
+
Bump version in version.rb manually, then run the following:
|
21
|
+
|
22
|
+
```shell
|
23
|
+
$ bundle exec git release v1.0.0
|
24
|
+
$ bundle exec rake release
|
25
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
3
|
+
require 'jdbc/jt400'
|
4
|
+
Jdbc::JT400.load_driver
|
5
|
+
|
6
|
+
Sequel.require 'adapters/jdbc/transactions'
|
7
|
+
Sequel.require 'adapters/utils/emulate_offset_with_row_number'
|
8
|
+
|
9
|
+
module Sequel
|
10
|
+
module JDBC
|
11
|
+
Sequel.synchronize do
|
12
|
+
DATABASE_SETUP[:as400] = proc do |db|
|
13
|
+
db.extend(Sequel::JDBC::AS400::DatabaseMethods)
|
14
|
+
db.dataset_class = Sequel::JDBC::AS400::Dataset
|
15
|
+
com.ibm.as400.access.AS400JDBCDriver
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Database and Dataset support for AS400 databases accessed via JDBC.
|
20
|
+
module AS400
|
21
|
+
# Instance methods for AS400 Database objects accessed via JDBC.
|
22
|
+
module DatabaseMethods
|
23
|
+
include Sequel::JDBC::Transactions
|
24
|
+
|
25
|
+
TRANSACTION_BEGIN = 'Transaction.begin'.freeze
|
26
|
+
Sequel::Deprecation.deprecate_constant(self, :TRANSACTION_BEGIN)
|
27
|
+
TRANSACTION_COMMIT = 'Transaction.commit'.freeze
|
28
|
+
Sequel::Deprecation.deprecate_constant(self, :TRANSACTION_COMMIT)
|
29
|
+
TRANSACTION_ROLLBACK = 'Transaction.rollback'.freeze
|
30
|
+
Sequel::Deprecation.deprecate_constant(self, :TRANSACTION_ROLLBACK)
|
31
|
+
|
32
|
+
# AS400 uses the :as400 database type.
|
33
|
+
def database_type
|
34
|
+
:as400
|
35
|
+
end
|
36
|
+
|
37
|
+
# TODO: Fix for AS400
|
38
|
+
def last_insert_id(_conn, _opts = OPTS)
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
|
42
|
+
# AS400 supports transaction isolation levels
|
43
|
+
def supports_transaction_isolation_levels?
|
44
|
+
true
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def disconnect_error?(exception, opts)
|
50
|
+
super || exception.message =~ /\A(The connection does not exist|Communication link failure)\./
|
51
|
+
end
|
52
|
+
|
53
|
+
# Use JDBC connection's setAutoCommit to false to start transactions
|
54
|
+
def begin_transaction(conn, opts = OPTS)
|
55
|
+
set_transaction_isolation(conn, opts)
|
56
|
+
super
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Dataset class for AS400 datasets accessed via JDBC.
|
61
|
+
class Dataset < JDBC::Dataset
|
62
|
+
include EmulateOffsetWithRowNumber
|
63
|
+
|
64
|
+
WILDCARD = Sequel::LiteralString.new('*').freeze
|
65
|
+
Sequel::Deprecation.deprecate_constant(self, :WILDCARD)
|
66
|
+
FETCH_FIRST_ROW_ONLY = ' FETCH FIRST ROW ONLY'.freeze
|
67
|
+
Sequel::Deprecation.deprecate_constant(self, :FETCH_FIRST_ROW_ONLY)
|
68
|
+
FETCH_FIRST = ' FETCH FIRST '.freeze
|
69
|
+
Sequel::Deprecation.deprecate_constant(self, :FETCH_FIRST)
|
70
|
+
ROWS_ONLY = ' ROWS ONLY'.freeze
|
71
|
+
Sequel::Deprecation.deprecate_constant(self, :ROWS_ONLY)
|
72
|
+
|
73
|
+
# Modify the sql to limit the number of rows returned
|
74
|
+
def select_limit_sql(sql)
|
75
|
+
l = @opts[:limit]
|
76
|
+
return unless l
|
77
|
+
|
78
|
+
if l == 1
|
79
|
+
sql << ' FETCH FIRST ROW ONLY'
|
80
|
+
elsif l > 1
|
81
|
+
sql << ' FETCH FIRST '
|
82
|
+
literal_append(sql, l)
|
83
|
+
sql << ' ROWS ONLY'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def supports_window_functions?
|
88
|
+
true
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path('../lib/sequel/jdbc/as400/version', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'sequel-jdbc-as400'
|
5
|
+
s.version = Sequel::JDBC::AS400::VERSION
|
6
|
+
s.platform = Gem::Platform::RUBY
|
7
|
+
s.summary = 'The Database Toolkit for Ruby: JDBC AS400 driver'
|
8
|
+
s.description = s.summary
|
9
|
+
s.author = 'Jeremy Evans and contributors'
|
10
|
+
s.homepage = 'https://github.com/ecraft/sequel-jdbc-as400'
|
11
|
+
s.license = 'MIT'
|
12
|
+
s.required_ruby_version = '>= 1.8.7'
|
13
|
+
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
14
|
+
s.require_path = 'lib'
|
15
|
+
s.bindir = 'bin'
|
16
|
+
|
17
|
+
s.add_runtime_dependency 'jdbc-jt400'
|
18
|
+
s.add_runtime_dependency 'sequel', '~> 5.0'
|
19
|
+
s.add_development_dependency 'activemodel'
|
20
|
+
s.add_development_dependency 'nokogiri'
|
21
|
+
s.add_development_dependency 'rspec'
|
22
|
+
s.add_development_dependency 'rubocop'
|
23
|
+
s.add_development_dependency 'tzinfo'
|
24
|
+
s.add_development_dependency 'rake'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sequel-jdbc-as400
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeremy Evans and contributors
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-09-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
name: jdbc-jt400
|
20
|
+
prerelease: false
|
21
|
+
type: :runtime
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
33
|
+
name: sequel
|
34
|
+
prerelease: false
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
name: activemodel
|
48
|
+
prerelease: false
|
49
|
+
type: :development
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
name: nokogiri
|
62
|
+
prerelease: false
|
63
|
+
type: :development
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
name: rspec
|
76
|
+
prerelease: false
|
77
|
+
type: :development
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
name: rubocop
|
90
|
+
prerelease: false
|
91
|
+
type: :development
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
name: tzinfo
|
104
|
+
prerelease: false
|
105
|
+
type: :development
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
name: rake
|
118
|
+
prerelease: false
|
119
|
+
type: :development
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: 'The Database Toolkit for Ruby: JDBC AS400 driver'
|
126
|
+
email:
|
127
|
+
executables: []
|
128
|
+
extensions: []
|
129
|
+
extra_rdoc_files: []
|
130
|
+
files:
|
131
|
+
- ".gitignore"
|
132
|
+
- ".rspec"
|
133
|
+
- ".rubocop.yml"
|
134
|
+
- ".ruby-version"
|
135
|
+
- ".travis.yml"
|
136
|
+
- Gemfile
|
137
|
+
- MIT-LICENSE
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- lib/sequel/jdbc/as400.rb
|
141
|
+
- lib/sequel/jdbc/as400/version.rb
|
142
|
+
- sequel-jdbc-as400.gemspec
|
143
|
+
homepage: https://github.com/ecraft/sequel-jdbc-as400
|
144
|
+
licenses:
|
145
|
+
- MIT
|
146
|
+
metadata: {}
|
147
|
+
post_install_message:
|
148
|
+
rdoc_options: []
|
149
|
+
require_paths:
|
150
|
+
- lib
|
151
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: 1.8.7
|
156
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
requirements: []
|
162
|
+
rubyforge_project:
|
163
|
+
rubygems_version: 2.6.8
|
164
|
+
signing_key:
|
165
|
+
specification_version: 4
|
166
|
+
summary: 'The Database Toolkit for Ruby: JDBC AS400 driver'
|
167
|
+
test_files: []
|