activerecord-jdbcas400-adapter 1.3.5 → 1.3.5.1

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: a2398fc7c8bad7ce1d3253f2e0f6a4a7b20d0ead
4
- data.tar.gz: 413c9f4b32caf45437b3acb22a5352159af1c152
3
+ metadata.gz: c136b73119611c7dba20169f0921eb7225360c06
4
+ data.tar.gz: 0f36b3c6cd877923a4a8f055aa83e4b71a64e192
5
5
  SHA512:
6
- metadata.gz: 6cacc8de3cf7d3b33e607007d5cbdd5d9b55dd6bb9cb358be734637076852d75ffb95bf2cea112bc7ee46817580ee4ce00261ed097073cb6674f5109028665f5
7
- data.tar.gz: b57c5cb53826fa1d07a54576b9eae158e08f40fd348b58dd75f80814d9aad8c1718fb0d81a75a942779dd57e0d53c5c658295e8b885f8d7e8dbc0bf24b1e7c09
6
+ metadata.gz: 652c1cb9571c772449eb121a535077ea8939d7ffe4d36997cb0f840341c89b283ba62cdada59e68ac335c60e3225dbdac6574d07479fc50cc443acbb8b91a9c5
7
+ data.tar.gz: a6470d8d57f2c10b4470ffac84a9c42375ba3af0294632736bf2bac274badd9b1de625c87676d7b5f6e55523850d17d912a710e90834a5ac23f1549f6559ac78
data/README.md CHANGED
@@ -6,6 +6,20 @@ https://github.com/pierrickrouxel/activerecord-jdbcas400-adapter/
6
6
 
7
7
  This is an ActiveRecord driver for AS/400 using JDBC running under JRuby.
8
8
 
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'activerecord-jdbcas400-adapter'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install activerecord-jdbcas400-adapter
22
+
9
23
  ## Usage
10
24
 
11
25
  Configure your database.yml in the normal Rails style:
data/Rakefile CHANGED
@@ -1,3 +1,2 @@
1
1
  require 'bundler/gem_helper'
2
2
  Bundler::GemHelper.install_tasks
3
- require File.expand_path '../../rakelib/bundler_ext', __FILE__
@@ -41,7 +41,7 @@ module ArJdbc
41
41
  if config[:current_library]
42
42
  @connection.tables(nil, config[:current_library])
43
43
  else
44
- @connection.tables(nil, db2_schema)
44
+ @connection.tables(nil, schema)
45
45
  end
46
46
  end
47
47
 
@@ -59,12 +59,9 @@ module ArJdbc
59
59
 
60
60
  # @override
61
61
  def prefetch_primary_key?(table_name = nil)
62
- # TRUE if the table has no identity column
63
- names = table_name.upcase.split(".")
64
- sql = "SELECT 1 FROM SYSIBM.SQLPRIMARYKEYS WHERE "
65
- sql << "TABLE_SCHEM = '#{names.first}' AND " if names.size == 2
66
- sql << "TABLE_NAME = '#{names.last}'"
67
- select_one(sql).nil?
62
+ return true if table_name.nil?
63
+ table_name = table_name.to_s
64
+ columns(table_name).count { |column| column.primary } == 0
68
65
  end
69
66
 
70
67
  # @override
@@ -113,29 +110,34 @@ module ArJdbc
113
110
  # Disable all schemas browsing
114
111
  def table_exists?(name)
115
112
  return false unless name
116
- @connection.table_exists?(name, db2_schema)
113
+ @connection.table_exists?(name, schema)
117
114
  end
118
115
 
119
116
  def indexes(table_name, name = nil)
120
- @connection.indexes(table_name, name, db2_schema)
117
+ @connection.indexes(table_name, name, schema)
121
118
  end
122
119
 
123
120
  DRIVER_NAME = 'com.ibm.as400.access.AS400JDBCDriver'.freeze
124
121
 
122
+ # Set schema is it specified
123
+ def configure_connection
124
+ set_schema(config[:schema]) if config[:schema]
125
+ end
126
+
125
127
  # Do not return *LIBL as schema
126
128
  def schema
127
- system_naming? ? nil : db2_schema
129
+ db2_schema
128
130
  end
129
131
 
130
132
  private
131
133
  # If naming is really in system mode CURRENT_SCHEMA is *LIBL
132
134
  def system_naming?
133
- @db2_schema == '*LIBL'
135
+ schema == '*LIBL'
134
136
  end
135
137
 
136
138
  # SET SCHEMA statement put connection in sql naming
137
139
  def set_schema(schema)
138
- execute("SET SCHEMA #{schema}") unless system_naming?
140
+ execute("SET SCHEMA #{schema}")
139
141
  end
140
142
 
141
143
  # @override
@@ -0,0 +1,19 @@
1
+ require 'test_helper'
2
+
3
+ class TestAdapter < Test::Unit::TestCase
4
+ def test_prefetch_primary_key?
5
+ begin
6
+ connection.execute('CREATE TABLE test_table (test_column INTEGER)')
7
+ assert_true(connection.prefetch_primary_key?('test_table'))
8
+ ensure
9
+ connection.execute('DROP TABLE test_table')
10
+ end
11
+
12
+ begin
13
+ connection.execute('CREATE TABLE test_table (test_column INTEGER, PRIMARY KEY(test_column))')
14
+ assert_false(connection.prefetch_primary_key?('test_table'))
15
+ ensure
16
+ connection.execute('DROP TABLE test_table')
17
+ end
18
+ end
19
+ end
@@ -7,11 +7,9 @@ class TestConnection < Test::Unit::TestCase
7
7
  end
8
8
 
9
9
  def test_schema
10
- assert_equal(connection.instance_eval {db2_schema}, config[:schema])
11
10
  assert_equal(connection.schema, config[:schema])
12
11
 
13
- assert_equal(system_connection.instance_eval {db2_schema}, '*LIBL')
14
- assert_nil(system_connection.schema)
12
+ assert_equal(system_connection.schema, '*LIBL')
15
13
  end
16
14
 
17
15
  def test_migration_support
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class TestConnection < Test::Unit::TestCase
3
+ class TestDatabaseTasks < Test::Unit::TestCase
4
4
  def test_tasks_registered
5
5
  adapter_name = connection.config[:adapter]
6
6
  assert_nothing_raised do
data/test/test_helper.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  require 'java'
2
2
 
3
- require 'rubygems'
4
- require 'bundler/setup'
5
- Bundler.require(:default, :test)
3
+ require 'test-unit'
4
+ require 'activerecord-jdbc-adapter'
6
5
 
7
6
  class Test::Unit::TestCase
8
7
  def config
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-jdbcas400-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.5
4
+ version: 1.3.5.1
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: 2014-01-20 00:00:00.000000000 Z
11
+ date: 2014-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-jdbc-adapter
@@ -24,6 +24,62 @@ dependencies:
24
24
  version: 1.3.5
25
25
  prerelease: false
26
26
  type: :runtime
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: '1.5'
39
+ prerelease: false
40
+ type: :development
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ prerelease: false
54
+ type: :development
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ prerelease: false
68
+ type: :development
69
+ - !ruby/object:Gem::Dependency
70
+ name: jdbc-as400
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ prerelease: false
82
+ type: :development
27
83
  description: Install this gem to use AS/400 with JRuby on Rails.
28
84
  email: nick@nicksieger.com, ola.bini@gmail.com
29
85
  executables: []
@@ -40,6 +96,7 @@ files:
40
96
  - lib/arjdbc/as400/adapter.rb
41
97
  - lib/arjdbc/as400/connection_methods.rb
42
98
  - test/config.yml
99
+ - test/test_adapter.rb
43
100
  - test/test_connection.rb
44
101
  - test/test_database_tasks.rb
45
102
  - test/test_helper.rb
@@ -63,12 +120,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
120
  version: '0'
64
121
  requirements: []
65
122
  rubyforge_project: jruby-extras
66
- rubygems_version: 2.1.9
123
+ rubygems_version: 2.1.11
67
124
  signing_key:
68
125
  specification_version: 4
69
126
  summary: AS/400 JDBC adapter for JRuby on Rails.
70
127
  test_files:
71
128
  - test/config.yml
129
+ - test/test_adapter.rb
72
130
  - test/test_connection.rb
73
131
  - test/test_database_tasks.rb
74
132
  - test/test_helper.rb