ibm_db 1.5.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +4 -0
- data/LICENSE +1 -1
- data/ParameterizedQueries README +39 -0
- data/README +1 -1
- data/ext/ibm_db.c +663 -436
- data/ext/ruby_ibm_db.h +6 -2
- data/ext/ruby_ibm_db_cli.c +3 -3
- data/ext/ruby_ibm_db_cli.h +17 -8
- data/lib/IBM_DB.rb +1 -1
- data/lib/active_record/connection_adapters/ibm_db_adapter.rb +383 -70
- data/lib/active_record/connection_adapters/ibm_db_pstmt.rb +1902 -0
- data/test/cases/calculations_test.rb +5 -1
- data/test/cases/helper.rb +75 -0
- data/test/connections/native_ibm_db/connection.rb +26 -24
- data/test/schema/schema.rb +1 -0
- metadata +5 -2
@@ -168,7 +168,11 @@ class CalculationsTest < ActiveRecord::TestCase
|
|
168
168
|
end
|
169
169
|
|
170
170
|
def test_should_group_by_association_with_non_numeric_foreign_key
|
171
|
-
ActiveRecord::Base.connection.
|
171
|
+
if( ActiveRecord::Base.connection.respond_to?(:pstmt_support_on) && ActiveRecord::Base.connection.pstmt_support_on == true )
|
172
|
+
ActiveRecord::Base.connection.expects(:prepared_select).returns([{"count_all" => 1, "firm_id" => "ABC"}])
|
173
|
+
else
|
174
|
+
ActiveRecord::Base.connection.expects(:select_all).returns([{"count_all" => 1, "firm_id" => "ABC"}])
|
175
|
+
end
|
172
176
|
|
173
177
|
firm = mock()
|
174
178
|
firm.expects(:id).returns("ABC")
|
@@ -0,0 +1,75 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
+
$:.unshift(File.dirname(__FILE__) + '/../../../activesupport/lib')
|
3
|
+
|
4
|
+
require 'config'
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'test/unit'
|
8
|
+
require 'stringio'
|
9
|
+
|
10
|
+
require 'active_record'
|
11
|
+
require 'active_record/test_case'
|
12
|
+
require 'active_record/fixtures'
|
13
|
+
require 'connection'
|
14
|
+
|
15
|
+
require 'cases/repair_helper'
|
16
|
+
|
17
|
+
# Show backtraces for deprecated behavior for quicker cleanup.
|
18
|
+
ActiveSupport::Deprecation.debug = true
|
19
|
+
|
20
|
+
# Quote "type" if it's a reserved word for the current connection.
|
21
|
+
QUOTED_TYPE = ActiveRecord::Base.connection.quote_column_name('type')
|
22
|
+
|
23
|
+
def current_adapter?(*types)
|
24
|
+
types.any? do |type|
|
25
|
+
ActiveRecord::ConnectionAdapters.const_defined?(type) &&
|
26
|
+
ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters.const_get(type))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
ActiveRecord::Base.connection.class.class_eval do
|
31
|
+
IGNORED_SQL = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/, /SHOW FIELDS/]
|
32
|
+
|
33
|
+
def execute_with_query_record(sql, name = nil, &block)
|
34
|
+
$queries_executed ||= []
|
35
|
+
$queries_executed << sql unless IGNORED_SQL.any? { |r| sql =~ r }
|
36
|
+
execute_without_query_record(sql, name, &block)
|
37
|
+
end
|
38
|
+
|
39
|
+
def execute_prepared_stmt_with_query_record(pstmt, param_array = nil)
|
40
|
+
$queries_executed ||= []
|
41
|
+
$queries_executed << "#{@prepared_sql} + #{param_array}" unless IGNORED_SQL.any? { |r| @prepared_sql =~ r }
|
42
|
+
execute_prepared_stmt_without_query_record(pstmt, param_array)
|
43
|
+
end
|
44
|
+
|
45
|
+
alias_method_chain :execute, :query_record
|
46
|
+
alias_method_chain :execute_prepared_stmt, :query_record
|
47
|
+
end
|
48
|
+
|
49
|
+
# Make with_scope public for tests
|
50
|
+
class << ActiveRecord::Base
|
51
|
+
public :with_scope, :with_exclusive_scope
|
52
|
+
end
|
53
|
+
|
54
|
+
unless ENV['FIXTURE_DEBUG']
|
55
|
+
module ActiveRecord::TestFixtures::ClassMethods
|
56
|
+
def try_to_load_dependency_with_silence(*args)
|
57
|
+
ActiveRecord::Base.logger.silence { try_to_load_dependency_without_silence(*args)}
|
58
|
+
end
|
59
|
+
|
60
|
+
alias_method_chain :try_to_load_dependency, :silence
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class ActiveSupport::TestCase
|
65
|
+
include ActiveRecord::TestFixtures
|
66
|
+
include ActiveRecord::Testing::RepairHelper
|
67
|
+
|
68
|
+
self.fixture_path = FIXTURES_ROOT
|
69
|
+
self.use_instantiated_fixtures = false
|
70
|
+
self.use_transactional_fixtures = true
|
71
|
+
|
72
|
+
def create_fixtures(*table_names, &block)
|
73
|
+
Fixtures.create_fixtures(ActiveSupport::TestCase.fixture_path, table_names, {}, &block)
|
74
|
+
end
|
75
|
+
end
|
@@ -7,32 +7,34 @@ ActiveRecord::Base.logger.level = Logger::FATAL
|
|
7
7
|
|
8
8
|
ActiveRecord::Base.configurations = {
|
9
9
|
'arunit' => {
|
10
|
-
:adapter
|
11
|
-
:username
|
12
|
-
:password
|
13
|
-
:host
|
14
|
-
:port
|
15
|
-
:schema
|
16
|
-
:account
|
17
|
-
:app_user
|
18
|
-
:application
|
19
|
-
:workstation
|
20
|
-
:start_id
|
21
|
-
:database
|
10
|
+
:adapter => 'ibm_db',
|
11
|
+
:username => 'db2user',
|
12
|
+
:password => 'secret',
|
13
|
+
:host => 'bilbao',
|
14
|
+
:port => '50000',
|
15
|
+
:schema => 'rails123',
|
16
|
+
:account => 'tester',
|
17
|
+
:app_user => 'tester_11',
|
18
|
+
:application => 'rails_tests',
|
19
|
+
:workstation => 'auckland',
|
20
|
+
:start_id => 100,
|
21
|
+
:database => 'ARUNIT',
|
22
|
+
:parameterized => false
|
22
23
|
},
|
23
24
|
'arunit2' => {
|
24
|
-
:adapter
|
25
|
-
:username
|
26
|
-
:password
|
27
|
-
:host
|
28
|
-
:port
|
29
|
-
:schema
|
30
|
-
:account
|
31
|
-
:app_user
|
32
|
-
:application
|
33
|
-
:workstation
|
34
|
-
:start_id
|
35
|
-
:database
|
25
|
+
:adapter => 'ibm_db',
|
26
|
+
:username => 'db2user',
|
27
|
+
:password => 'secret',
|
28
|
+
:host => 'bilbao',
|
29
|
+
:port => '50000',
|
30
|
+
:schema => 'rails123',
|
31
|
+
:account => 'tester',
|
32
|
+
:app_user => 'tester_11',
|
33
|
+
:application => 'rails_tests',
|
34
|
+
:workstation => 'auckland',
|
35
|
+
:start_id => 100,
|
36
|
+
:database => 'ARUNIT2',
|
37
|
+
:parameterized => false
|
36
38
|
}
|
37
39
|
}
|
38
40
|
|
data/test/schema/schema.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ibm_db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IBM
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-21 00:00:00 +05:30
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -35,6 +35,7 @@ extra_rdoc_files:
|
|
35
35
|
files:
|
36
36
|
- README
|
37
37
|
- lib/active_record/connection_adapters/ibm_db_adapter.rb
|
38
|
+
- lib/active_record/connection_adapters/ibm_db_pstmt.rb
|
38
39
|
- lib/active_record/vendor/db2-i5-zOS.yaml
|
39
40
|
- lib/IBM_DB.rb
|
40
41
|
- test/connections/native_ibm_db/connection.rb
|
@@ -44,6 +45,7 @@ files:
|
|
44
45
|
- test/cases/schema_dumper_test.rb
|
45
46
|
- test/cases/validations_test.rb
|
46
47
|
- test/cases/fixtures_test.rb
|
48
|
+
- test/cases/helper.rb
|
47
49
|
- test/cases/calculations_test.rb
|
48
50
|
- test/cases/migration_test.rb
|
49
51
|
- test/cases/base_test.rb
|
@@ -59,6 +61,7 @@ files:
|
|
59
61
|
- test/schema/schema.rb
|
60
62
|
- test/schema/luw/ibm_db_specific_schema.rb
|
61
63
|
- test/ibm_db_test.rb
|
64
|
+
- ParameterizedQueries README
|
62
65
|
- ext/ruby_ibm_db.h
|
63
66
|
- ext/Makefile.nt32
|
64
67
|
- ext/ruby_ibm_db_cli.c
|