activerecord-jdbcas400-adapter 1.3.19 → 1.3.20

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: e7c9181a3a661ce9e1b9264e06b22c26ac9cbf40
4
- data.tar.gz: 3885e230dfcd4a88ab88ed44c6be08d8d45064a9
3
+ metadata.gz: 3a626eafcb49f65572a0b225f6c06881350d5113
4
+ data.tar.gz: 21d49dbbf66be37b547df5317c7e60d583e3df47
5
5
  SHA512:
6
- metadata.gz: fdb11030d59143c8069ab0da0c7aade664d35d88372d1990927779407728af9ad8d111931a95f0600521d07d984dbfdffe3db141e494c362511ad838742ffc3c
7
- data.tar.gz: 55c30fb2e15856e5a60e70dce44afe077c0f9165402e7bac272c6f1a92714f85be0dd96681eaae2a5cffedef6a0785b95d09a0af3eefd46cf3517deca803ae11
6
+ metadata.gz: 5756b10272558e6c2c0927f019546bc76c5ea3def1fc18ca34fd2d0875852a3f8eb695c6f318b03681ff5619bdacd46d48370b1f2ddd1eb77ed28aa91ee595bd
7
+ data.tar.gz: a023e55ac0d04531767a3322e5cb2bf3059287359d818bccae2ffa34aa6cf9c7c7e374247ba90f98f09bad4787444265f48365b7dab966fff1f396746dd9bc15
data/README.md CHANGED
@@ -63,7 +63,7 @@ To use native DB2 connection (directly on IBM i JVM only), you can add this to d
63
63
  ```
64
64
  This connection doesn't require credentials.
65
65
 
66
- ### Transaction isolation : no commit
66
+ ### Transaction isolation: no commit
67
67
  If your database supports setting the isolation level for a transaction, you can set it like so:
68
68
 
69
69
  ```ruby
@@ -89,7 +89,7 @@ To allow migrations with system naming, a configuration is added to adapter:
89
89
  current_library: lib
90
90
  ```
91
91
 
92
- The specified library will be used to define a schema during create_table migration.
92
+ The specified library will be used to define a schema during `create_table` migration.
93
93
  It prevents creation of a table in QGPL.
94
94
 
95
95
  If you want to use it with JNDI you can create a JNDI string and use erb in yaml to do something like this:
data/lib/arjdbc/as400.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'arjdbc'
2
2
  require 'arjdbc/db2/adapter'
3
3
  require 'arjdbc/as400/connection_methods'
4
- require 'arjdbc/as400/system'
5
4
  require 'arjdbc/as400/adapter'
6
5
 
7
6
  # Register AS400 to database tasks
@@ -13,4 +12,4 @@ module ArJdbc
13
12
  register_tasks(/as400/, DB2DatabaseTasks)
14
13
 
15
14
  end
16
- end
15
+ end
@@ -1,7 +1,6 @@
1
1
  module ArJdbc
2
2
  module AS400
3
3
  include DB2
4
- include System
5
4
 
6
5
  # @private
7
6
  def self.extended(adapter); DB2.extended(adapter); end
@@ -37,7 +36,9 @@ module ArJdbc
37
36
  # Set schema is it specified
38
37
  def configure_connection
39
38
  set_schema(config[:schema]) if config[:schema]
40
- change_current_library(config[:current_library]) if config[:current_library]
39
+ if config[:current_library]
40
+ execute_system_command("CHGCURLIB CURLIB(#{config[:current_library]})")
41
+ end
41
42
  end
42
43
 
43
44
  def os400_version
@@ -47,15 +48,15 @@ module ArJdbc
47
48
  { major: major, minor: minor }
48
49
  end
49
50
 
50
- # Do not return *LIBL as schema
51
+ # Do not return *LIBL
51
52
  def schema
52
- db2_schema
53
+ db2_schema == '*LIBL' ? @current_library : db2_schema
53
54
  end
54
55
 
55
56
  def tables(name = nil)
56
57
  # Do not perform search on all system
57
58
  if system_naming?
58
- name ||= current_library
59
+ name ||= @current_library
59
60
  unless name
60
61
  raise StandardError.new('Unable to retrieve tables without current library')
61
62
  end
@@ -64,11 +65,6 @@ module ArJdbc
64
65
  @connection.tables(nil, name)
65
66
  end
66
67
 
67
- # Prevent migration in QGPL
68
- def supports_migrations?
69
- !(system_naming? && !current_library?)
70
- end
71
-
72
68
  # If true, next_sequence_value is called before each insert statement
73
69
  # to set the record's primary key.
74
70
  # By default DB2 for i supports IDENTITY_VAL_LOCAL for tables that have
@@ -126,9 +122,14 @@ module ArJdbc
126
122
  end
127
123
 
128
124
  private
125
+ def execute_system_command(command)
126
+ command = quote(command)
127
+ execute("CALL qsys2.qcmdexc(#{command})")
128
+ end
129
+
129
130
  # If naming is really in system mode CURRENT_SCHEMA is *LIBL
130
131
  def system_naming?
131
- schema == '*LIBL'
132
+ db2_schema == '*LIBL'
132
133
  end
133
134
 
134
135
  # SET SCHEMA statement put connection in sql naming
data/test/adapter_test.rb CHANGED
@@ -3,8 +3,8 @@ require 'test_helper'
3
3
  class TestAdapter < Test::Unit::TestCase
4
4
 
5
5
  def test_schema
6
- assert_equal(connection.schema, config[:schema])
7
- assert_equal(system_connection.schema, '*LIBL')
6
+ assert_equal(config[:schema], connection.schema)
7
+ assert_equal(nil, system_connection.schema)
8
8
  end
9
9
 
10
10
  def test_system_naming?
@@ -12,16 +12,6 @@ class TestAdapter < Test::Unit::TestCase
12
12
  assert_true(system_connection.instance_eval {system_naming?})
13
13
  end
14
14
 
15
- def test_supports_migrations?
16
- assert_true(connection.supports_migrations?)
17
-
18
- system_connection.change_current_library('QGPL')
19
- assert_true(system_connection.supports_migrations?)
20
-
21
- system_connection.change_current_library(nil)
22
- assert_false(system_connection.supports_migrations?)
23
- end
24
-
25
15
  def test_prefetch_primary_key?
26
16
  begin
27
17
  connection.execute('CREATE TABLE test_table (test_column INTEGER)')
@@ -66,14 +56,23 @@ class TestAdapter < Test::Unit::TestCase
66
56
 
67
57
  connection.rename_column('test_table', 'test_column', 'new_test_column')
68
58
  assert_not_nil(connection.columns('test_table').find { |column| column.name == 'new_test_column' })
69
- assert_equal(connection.select_one('SELECT new_test_column FROM test_table')['new_test_column'], 1)
59
+ assert_equal(1, connection.select_one('SELECT new_test_column FROM test_table')['new_test_column'])
70
60
  ensure
71
61
  connection.execute('DROP TABLE test_table')
72
62
  end
73
63
  end
74
64
 
75
65
  def test_transaction_isolation_levels
76
- assert_equal(connection.transaction_isolation_levels.fetch(:no_commit), 'NO COMMIT')
66
+ assert_equal('NO COMMIT', connection.transaction_isolation_levels.fetch(:no_commit))
67
+ end
68
+
69
+ def test_table_exists
70
+ begin
71
+ connection.execute('CREATE TABLE test_table (test_column INTEGER)')
72
+ assert_true(system_connection.table_exists?('test_table'))
73
+ ensure
74
+ connection.execute('DROP TABLE test_table')
75
+ end
77
76
  end
78
77
 
79
78
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-jdbcas400-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.19
4
+ version: 1.3.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sieger, Ola Bini, Pierrick Rouxel and JRuby contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-01 00:00:00.000000000 Z
11
+ date: 2016-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- requirement: !ruby/object:Gem::Requirement
15
- requirements:
16
- - - '>='
17
- - !ruby/object:Gem::Version
18
- version: 3.0.0
19
- name: activerecord
20
- prerelease: false
21
- type: :runtime
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: 3.0.0
27
13
  - !ruby/object:Gem::Dependency
28
14
  requirement: !ruby/object:Gem::Requirement
29
15
  requirements:
@@ -80,6 +66,26 @@ dependencies:
80
66
  - - '>='
81
67
  - !ruby/object:Gem::Version
82
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: 3.0.0
75
+ - - <
76
+ - !ruby/object:Gem::Version
77
+ version: 5.0.0
78
+ name: activerecord
79
+ prerelease: false
80
+ type: :development
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: 3.0.0
86
+ - - <
87
+ - !ruby/object:Gem::Version
88
+ version: 5.0.0
83
89
  description: Install this gem to use AS/400 with JRuby on Rails.
84
90
  email: nick@nicksieger.com, ola.bini@gmail.com
85
91
  executables: []
@@ -94,11 +100,9 @@ files:
94
100
  - lib/arjdbc/as400.rb
95
101
  - lib/arjdbc/as400/adapter.rb
96
102
  - lib/arjdbc/as400/connection_methods.rb
97
- - lib/arjdbc/as400/system.rb
98
103
  - lib/arjdbc/discover.rb
99
104
  - test/adapter_test.rb
100
105
  - test/database_tasks_test.rb
101
- - test/system_test.rb
102
106
  - test/test_helper.rb
103
107
  homepage: https://github.com/pierrickrouxel/activerecord-jdbcas400-adapter
104
108
  licenses:
@@ -127,5 +131,4 @@ summary: AS/400 JDBC adapter for JRuby on Rails.
127
131
  test_files:
128
132
  - test/adapter_test.rb
129
133
  - test/database_tasks_test.rb
130
- - test/system_test.rb
131
134
  - test/test_helper.rb
@@ -1,38 +0,0 @@
1
- module ArJdbc
2
- module AS400
3
- module System
4
-
5
- # Execute system command with QSYS.QCMDEXC
6
- def execute_system_command(command)
7
- length = command.length
8
- command = quote(command)
9
- execute("CALL QSYS.QCMDEXC(#{command}, CAST(#{length} AS DECIMAL(15, 5)))")
10
- end
11
-
12
- # Change current library
13
- def change_current_library(current_library)
14
- @current_library = current_library
15
- # *CRTDFT is the nil equivalent for current library
16
- current_library ||= '*CRTDFT'
17
- execute_system_command("CHGCURLIB CURLIB(#{current_library})")
18
- end
19
-
20
- # Change libraries
21
- def change_libraries(libraries)
22
- libraries = libraries.nil? || libraries.size < 1 ? '*NONE' :libraries.join(' ')
23
- execute_system_command("CHGLIBL LIBL(#{libraries})")
24
- end
25
-
26
- # Returns true if current library is configured
27
- def current_library?
28
- !current_library.nil?
29
- end
30
-
31
- # Returns the name current library
32
- def current_library
33
- @current_library
34
- end
35
-
36
- end
37
- end
38
- end
data/test/system_test.rb DELETED
@@ -1,36 +0,0 @@
1
- require 'test_helper'
2
-
3
- class TestAdapter < Test::Unit::TestCase
4
- def test_execute_system_command
5
- assert_nothing_raised do
6
- connection.execute_system_command('DSPJOBLOG')
7
- end
8
- end
9
-
10
- def test_change_current_library
11
- connection = system_connection
12
- assert_nothing_raised do
13
- connection.change_current_library('QGPL')
14
- connection.change_current_library(nil)
15
- end
16
- end
17
-
18
- def test_current_library
19
- connection = system_connection
20
- connection.change_current_library('QSYS')
21
- assert_equal(connection.current_library, 'QSYS')
22
- assert_true(connection.current_library?)
23
-
24
- connection.change_current_library(nil)
25
- assert_nil(connection.current_library)
26
- assert_false(connection.current_library?)
27
- end
28
-
29
- def test_change_libraries
30
- connection = system_connection
31
- assert_nothing_raised do
32
- connection.change_libraries(%w(QGPL QTEMP))
33
- connection.change_libraries(nil)
34
- end
35
- end
36
- end