activerecord-jdbcas400-adapter 1.3.4.1 → 1.3.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17117e85ff715297a6f0eae81bc6396bf42e37f0
4
- data.tar.gz: 7ec82609586834ec4a759e751a1c9da610b601fa
3
+ metadata.gz: db46adedfc6af99ae702410e95165bdc5d4f265f
4
+ data.tar.gz: cfe0595abb8d7615c931fba9ad6d023bf77afe18
5
5
  SHA512:
6
- metadata.gz: 10cddd83ee5fc0ce0e5dc03465259726be5d619278c46decd8fd3522d53ea45d419acb55f4355aea01091ccc300e5481a819e875b57bdb7fba9405b58f50acce
7
- data.tar.gz: 02982ff31b1d1a7ebe2cc6ce37be72fa72c8a34f26718fad50b63cfe45ed5cc2c54d821eb18ea052f5a877bc7794fd8b71dc66f2152344c2575b49298377697e
6
+ metadata.gz: 79ee6fd3f690309158c8aa3f8132c1f86517f71eb9187d028005d28f201b9d52c27e4f25105057d3c782b4d9c82870eab86c6facbaddc4dd4d9d0b7e495c5321
7
+ data.tar.gz: fe1a6897bf5510aa0f99873faf909f00136e784ea046c8da39ff335bc3442c7965f9d242ab91b7f233ab0bd232ca26bc64c386233e05e22f40b8001b19b2d813
data/README.md CHANGED
@@ -15,13 +15,18 @@ development:
15
15
  database: development
16
16
  username: user
17
17
  password: 1234
18
+
19
+ naming: sql
20
+
21
+ # This is possible only if naming=system and schema isn't defined
22
+ libraries: lib1,lib2,lib3
18
23
  ```
19
24
 
20
25
  You cas also use JNDI in production mode:
21
26
  ```yml
22
27
  production:
23
28
  adapter: jndi # jdbc
24
- jndi: jdbc/DataSource
29
+ jndi: jdbc/dataSource
25
30
  ```
26
31
 
27
32
  If your DB isn't correctly discovered you can specify the dialect:
@@ -60,8 +60,8 @@ module ArJdbc
60
60
  def execute_and_auto_confirm(sql, name = nil)
61
61
 
62
62
  begin
63
- @connection.execute_update "call qsys.qcmdexc('QSYS/CHGJOB INQMSGRPY(*SYSRPYL)',0000000031.00000)"
64
- @connection.execute_update "call qsys.qcmdexc('ADDRPYLE SEQNBR(9876) MSGID(CPA32B2) RPY(''I'')',0000000045.00000)"
63
+ @connection.execute_update "CALL qsys.qcmdexc('QSYS/CHGJOB INQMSGRPY(*SYSRPYL)', 0000000031.00000)"
64
+ @connection.execute_update "CALL qsys.qcmdexc('ADDRPYLE SEQNBR(9876) MSGID(CPA32B2) RPY(''I'')', 0000000045.00000)"
65
65
  rescue Exception => e
66
66
  raise "Could not call CHGJOB INQMSGRPY(*SYSRPYL) and ADDRPYLE SEQNBR(9876) MSGID(CPA32B2) RPY('I').\n" +
67
67
  "Do you have authority to do this?\n\n#{e.inspect}"
@@ -78,8 +78,8 @@ module ArJdbc
78
78
 
79
79
  # Ensure default configuration restoration
80
80
  begin
81
- @connection.execute_update "call qsys.qcmdexc('QSYS/CHGJOB INQMSGRPY(*DFT)',0000000027.00000)"
82
- @connection.execute_update "call qsys.qcmdexc('RMVRPYLE SEQNBR(9876)',0000000021.00000)"
81
+ @connection.execute_update "CALL qsys.qcmdexc('QSYS/CHGJOB INQMSGRPY(*DFT)', 0000000027.00000)"
82
+ @connection.execute_update "CALL qsys.qcmdexc('RMVRPYLE SEQNBR(9876)', 0000000021.00000)"
83
83
  rescue Exception => e
84
84
  raise "Could not call CHGJOB INQMSGRPY(*DFT) and RMVRPYLE SEQNBR(9876).\n" +
85
85
  "Do you have authority to do this?\n\n#{e.inspect}"
@@ -89,46 +89,44 @@ module ArJdbc
89
89
  end
90
90
  private :execute_and_auto_confirm
91
91
 
92
- # disable all schemas browsing when default schema is specified
92
+ # Disable all schemas browsing
93
93
  def table_exists?(name)
94
94
  return false unless name
95
- schema ? @connection.table_exists?(name, schema) : @connection.table_exists?(name)
95
+ @connection.table_exists?(name, db2_schema)
96
+ end
97
+
98
+ def indexes(table_name, name = nil)
99
+ @connection.indexes(table_name, name, db2_schema)
96
100
  end
97
101
 
98
102
  DRIVER_NAME = 'com.ibm.as400.access.AS400JDBCDriver'.freeze
99
103
 
100
- # @private
101
- # @deprecated no longer used
102
- def as400?
103
- true
104
+ # Do not return *LIBL as schema
105
+ def schema
106
+ system_naming? ? nil : db2_schema
104
107
  end
105
108
 
106
109
  private
110
+ # If naming is really in system mode CURRENT_SCHEMA is *LIBL
111
+ def system_naming?
112
+ @db2_schema == '*LIBL'
113
+ end
114
+
115
+ # SET SCHEMA statement put connection in sql naming
116
+ def set_schema(schema)
117
+ execute("SET SCHEMA #{schema}") unless system_naming?
118
+ end
107
119
 
108
120
  # @override
109
121
  def db2_schema
110
- @db2_schema = false unless defined? @db2_schema
111
- return @db2_schema if @db2_schema != false
122
+ return @db2_schema if defined? @db2_schema
112
123
  @db2_schema =
113
124
  if config[:schema].present?
114
125
  config[:schema]
115
- elsif config[:jndi].present?
126
+ else
116
127
  # Only found method to set db2_schema from jndi
117
128
  result = select_one("SELECT CURRENT_SCHEMA FROM SYSIBM.SYSDUMMY1")
118
- schema = result['00001']
119
- # If the connection uses the library list schema name will be nil
120
- if schema == '*LIBL'
121
- schema = nil
122
- end
123
- schema
124
- else
125
- # AS400 implementation takes schema from library name (last part of URL)
126
- # jdbc:as400://localhost/schema;naming=system;libraries=lib1,lib2
127
- schema = nil
128
- split = config[:url].split('/')
129
- # Return nil if schema isn't defined
130
- schema = split.last.split(';').first.strip if split.size == 4
131
- schema
129
+ result['00001']
132
130
  end
133
131
  end
134
132
 
@@ -8,13 +8,14 @@ ArJdbc::ConnectionMethods.module_eval do
8
8
  end
9
9
 
10
10
  config[:url] ||= begin
11
- # jdbc:as400://[host]
11
+ # jdbc:as400://[host];proxy server=[proxy:port];naming=[naming];libraries=[libraries];prompt=false
12
12
  url = 'jdbc:as400://'
13
13
  url << config[:host] if config[:host]
14
- # jdbc:as400://myiSeries;database name=IASP1
15
14
  url << ";database name=#{config[:database]}" if config[:database]
16
- # jdbc:as400://[host];proxy server=HODServerName:proxyServerPort
17
15
  url << ";proxy server=#{config[:proxy]}" if config[:proxy]
16
+ url << ";naming=#{config[:naming]}" if config[:naming]
17
+ url << ";libraries=#{config[:libraries]}" if config[:libraries]
18
+ url << ';prompt=false'
18
19
  url
19
20
  end
20
21
  require 'arjdbc/as400/adapter'
data/test/config.yml ADDED
@@ -0,0 +1,5 @@
1
+ host: 'inc400'
2
+ username: 'pr'
3
+ password: 'princ189'
4
+ schema: 'ARJDBC_TEST'
5
+ libraries: 'QTEMP,ARJDBC_TEST'
@@ -0,0 +1,16 @@
1
+ require 'test_helper'
2
+
3
+ class TestConnection < Test::Unit::TestCase
4
+ def test_system_naming
5
+ assert_false(connection.instance_eval {system_naming?})
6
+ assert_true(system_connection.instance_eval {system_naming?})
7
+ end
8
+
9
+ def test_schema
10
+ assert_equal(connection.instance_eval {db2_schema}, config[:schema])
11
+ assert_equal(connection.schema, config[:schema])
12
+
13
+ assert_equal(system_connection.instance_eval {db2_schema}, '*LIBL')
14
+ assert_nil(system_connection.schema)
15
+ end
16
+ end
@@ -0,0 +1,57 @@
1
+ require 'java'
2
+
3
+ begin
4
+ require 'bundler'
5
+ rescue LoadError => e
6
+ require('rubygems') && retry
7
+ raise e
8
+ end
9
+ Bundler.require(:default, :test)
10
+
11
+ class Test::Unit::TestCase
12
+ def config
13
+ @config ||= YAML::load(File.open('config.yml'))
14
+ @config.symbolize_keys
15
+ end
16
+
17
+ def data_source_connection
18
+ return @connection if @connection && @connection_type == 'data_source'
19
+ # Create a data source to the iSeries database.
20
+ datasource = com.ibm.as400.access.AS400JDBCDataSource.new
21
+ datasource.setServerName(config[:host])
22
+ datasource.setLibraries(config[:libraries])
23
+ datasource.setUser(config[:username])
24
+ datasource.setPassword(config[:password])
25
+
26
+ ActiveRecord::Base.establish_connection(adapter: 'as400', data_source: datasource)
27
+ @connection_type = 'data_source'
28
+ @connection = ActiveRecord::Base.connection
29
+ end
30
+
31
+ def connection
32
+ return @connection if @connection && @connection_type == 'connection'
33
+ ActiveRecord::Base.establish_connection(
34
+ adapter: 'as400',
35
+ host: config[:host],
36
+ username: config[:username],
37
+ password: config[:password],
38
+ schema: config[:schema]
39
+ )
40
+ @connection_type = 'connection'
41
+ @connection = ActiveRecord::Base.connection
42
+ end
43
+
44
+ def system_connection
45
+ return @connection if @connection && @connection_type == 'system'
46
+ ActiveRecord::Base.establish_connection(
47
+ adapter: 'as400',
48
+ host: config[:host],
49
+ username: config[:username],
50
+ password: config[:password],
51
+ naming: 'system',
52
+ libraries: config[:libraries]
53
+ )
54
+ @connection_type = 'system'
55
+ @connection = ActiveRecord::Base.connection
56
+ end
57
+ end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-jdbcas400-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4.1
4
+ version: 1.3.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sieger, Ola Bini, Pierrick Rouxel and JRuby contributors
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-30 00:00:00.000000000 Z
11
+ date: 2014-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-jdbc-adapter
15
- requirement: !ruby/object:Gem::Requirement
15
+ version_requirements: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.3.4
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
20
+ requirement: !ruby/object:Gem::Requirement
23
21
  requirements:
24
22
  - - '>='
25
23
  - !ruby/object:Gem::Version
26
24
  version: 1.3.4
25
+ prerelease: false
26
+ type: :runtime
27
27
  description: Install this gem to use AS/400 with JRuby on Rails.
28
28
  email: nick@nicksieger.com, ola.bini@gmail.com
29
29
  executables: []
@@ -33,16 +33,19 @@ files:
33
33
  - Rakefile
34
34
  - README.md
35
35
  - LICENSE.txt
36
- - lib/active_record/connection_adapters/as400_adapter.rb
37
36
  - lib/activerecord-jdbcas400-adapter.rb
38
- - lib/arjdbc/as400/adapter.rb
39
- - lib/arjdbc/as400/connection_methods.rb
37
+ - lib/active_record/connection_adapters/as400_adapter.rb
40
38
  - lib/arjdbc/as400.rb
41
39
  - lib/arjdbc/discover.rb
40
+ - lib/arjdbc/as400/adapter.rb
41
+ - lib/arjdbc/as400/connection_methods.rb
42
+ - test/config.yml
43
+ - test/test_connection.rb
44
+ - test/test_helper.rb
42
45
  homepage: https://github.com/pierrickrouxel/activerecord-jdbcas400-adapter
43
46
  licenses: []
44
47
  metadata: {}
45
- post_install_message:
48
+ post_install_message:
46
49
  rdoc_options: []
47
50
  require_paths:
48
51
  - lib
@@ -58,8 +61,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
61
  version: '0'
59
62
  requirements: []
60
63
  rubyforge_project: jruby-extras
61
- rubygems_version: 2.0.14
62
- signing_key:
64
+ rubygems_version: 2.1.11
65
+ signing_key:
63
66
  specification_version: 4
64
67
  summary: AS/400 JDBC adapter for JRuby on Rails.
65
- test_files: []
68
+ test_files:
69
+ - test/config.yml
70
+ - test/test_connection.rb
71
+ - test/test_helper.rb