db2 2.5.10 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGES +0 -17
  3. data/LICENSE +18 -0
  4. data/ParameterizedQueries README +39 -0
  5. data/README +141 -79
  6. data/ext/Makefile.nt32 +181 -0
  7. data/ext/extconf.rb +14 -75
  8. data/ext/ibm_db.c +11166 -0
  9. data/ext/ruby_ibm_db.h +236 -0
  10. data/ext/ruby_ibm_db_cli.c +738 -0
  11. data/ext/ruby_ibm_db_cli.h +431 -0
  12. data/init.rb +42 -0
  13. data/lib/IBM_DB.rb +2 -0
  14. data/lib/active_record/connection_adapters/ibm_db_adapter.rb +2557 -0
  15. data/lib/active_record/connection_adapters/ibm_db_pstmt.rb +1965 -0
  16. data/lib/active_record/vendor/db2-i5-zOS.yaml +328 -0
  17. data/test/cases/adapter_test.rb +202 -0
  18. data/test/cases/associations/belongs_to_associations_test.rb +486 -0
  19. data/test/cases/associations/cascaded_eager_loading_test.rb +183 -0
  20. data/test/cases/associations/eager_test.rb +862 -0
  21. data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +917 -0
  22. data/test/cases/associations/has_many_through_associations_test.rb +461 -0
  23. data/test/cases/associations/join_model_test.rb +793 -0
  24. data/test/cases/attribute_methods_test.rb +621 -0
  25. data/test/cases/base_test.rb +1486 -0
  26. data/test/cases/calculations_test.rb +362 -0
  27. data/test/cases/finder_test.rb +1088 -0
  28. data/test/cases/fixtures_test.rb +684 -0
  29. data/test/cases/migration_test.rb +2014 -0
  30. data/test/cases/schema_dumper_test.rb +232 -0
  31. data/test/cases/validations/uniqueness_validation_test.rb +283 -0
  32. data/test/connections/native_ibm_db/connection.rb +42 -0
  33. data/test/ibm_db_test.rb +25 -0
  34. data/test/models/warehouse_thing.rb +5 -0
  35. data/test/schema/i5/ibm_db_specific_schema.rb +135 -0
  36. data/test/schema/ids/ibm_db_specific_schema.rb +138 -0
  37. data/test/schema/luw/ibm_db_specific_schema.rb +135 -0
  38. data/test/schema/schema.rb +647 -0
  39. data/test/schema/zOS/ibm_db_specific_schema.rb +206 -0
  40. metadata +68 -32
@@ -0,0 +1,42 @@
1
+ print "Using native IBM_DB\n"
2
+ require_dependency 'models/course'
3
+ require 'logger'
4
+
5
+ ActiveRecord::Base.logger = Logger.new STDOUT
6
+ ActiveRecord::Base.logger.level = Logger::FATAL
7
+
8
+ ActiveRecord::Base.configurations = {
9
+ 'arunit' => {
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
23
+ },
24
+ 'arunit2' => {
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
38
+ }
39
+ }
40
+
41
+ ActiveRecord::Base.establish_connection 'arunit'
42
+ Course.establish_connection 'arunit2'
@@ -0,0 +1,25 @@
1
+ require 'test/unit'
2
+
3
+ class IBM_DBAdapterTest < Test::Unit::TestCase
4
+ require 'pathname'
5
+
6
+ # Fixture
7
+ def driver_lib_path
8
+ drv_path = Pathname.new(File.dirname(__FILE__)).parent + 'lib'
9
+ drv_path += (RUBY_PLATFORM =~ /mswin32/) ? 'mswin32' : 'linux32'
10
+ drv_path += 'ibm_db.so'
11
+ end
12
+
13
+ # Check IBM_DB Ruby driver for this platform: #{RUBY_PLATFORM}
14
+ def test_driver_existence
15
+ driver = driver_lib_path
16
+ assert driver.file?
17
+ end
18
+
19
+ # Attempt loading IBM_DB Ruby driver for this platform: #{RUBY_PLATFORM}
20
+ def test_driver_loading
21
+ driver = driver_lib_path
22
+ require "#{driver.to_s}"
23
+ assert true
24
+ end
25
+ end
@@ -0,0 +1,5 @@
1
+ class WarehouseThing < ActiveRecord::Base
2
+ set_table_name "warehouse_things"
3
+
4
+ validates_uniqueness_of :value
5
+ end
@@ -0,0 +1,135 @@
1
+ ActiveRecord::Schema.define do
2
+
3
+ execute "DROP TABLE COMMENTS" rescue nil
4
+ execute "DROP TABLE POSTS" rescue nil
5
+ execute "DROP TABLE ITEMS" rescue nil
6
+ execute "DROP TABLE TOPICS" rescue nil
7
+ execute "DROP TABLE fk_test_has_fk" rescue nil
8
+ execute "DROP TABLE fk_test_has_pk" rescue nil
9
+ execute "DROP TABLE CIRCLES" rescue nil
10
+ execute "DROP TABLE SQUARES" rescue nil
11
+ execute "DROP TABLE TRIANGLES" rescue nil
12
+ execute "DROP TABLE NON_POLY_ONES" rescue nil
13
+ execute "DROP TABLE NON_POLY_TWOS" rescue nil
14
+ execute "DROP TABLE PAINT_COLORS" rescue nil
15
+ execute "DROP TABLE PAINT_TEXTURES" rescue nil
16
+
17
+ execute <<_SQL
18
+ CREATE TABLE comments (
19
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
20
+ post_id INT NOT NULL,
21
+ type VARCHAR(255) DEFAULT NULL,
22
+ body VARCHAR(3000)NOT NULL,
23
+ PRIMARY KEY (id)
24
+ );
25
+ _SQL
26
+
27
+ execute <<_SQL
28
+ CREATE TABLE posts (
29
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
30
+ author_id INT DEFAULT NULL,
31
+ title VARCHAR(255) NOT NULL,
32
+ type VARCHAR(255) DEFAULT NULL,
33
+ body VARCHAR(3000) NOT NULL,
34
+ comments_count integer DEFAULT 0,
35
+ taggings_count integer DEFAULT 0,
36
+ PRIMARY KEY (id)
37
+ );
38
+ _SQL
39
+
40
+ execute <<_SQL
41
+ CREATE TABLE fk_test_has_pk (
42
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
43
+ PRIMARY KEY (id)
44
+ );
45
+ _SQL
46
+
47
+ execute <<_SQL
48
+ CREATE TABLE fk_test_has_fk (
49
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
50
+ fk_id integer NOT NULL,
51
+ PRIMARY KEY (id),
52
+ FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id)
53
+ );
54
+ _SQL
55
+
56
+ execute <<_SQL
57
+ CREATE TABLE items (
58
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
59
+ name VARCHAR(255) DEFAULT NULL,
60
+ PRIMARY KEY (id)
61
+ );
62
+ _SQL
63
+
64
+ execute <<_SQL
65
+ CREATE TABLE circles (
66
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
67
+ PRIMARY KEY (id)
68
+ );
69
+ _SQL
70
+
71
+ execute <<_SQL
72
+ CREATE TABLE squares(
73
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
74
+ PRIMARY KEY (id)
75
+ );
76
+ _SQL
77
+
78
+ execute <<_SQL
79
+ CREATE TABLE triangles(
80
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
81
+ PRIMARY KEY (id)
82
+ );
83
+ _SQL
84
+
85
+ execute <<_SQL
86
+ CREATE TABLE non_poly_ones(
87
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
88
+ PRIMARY KEY (id)
89
+ );
90
+ _SQL
91
+
92
+ execute <<_SQL
93
+ CREATE TABLE non_poly_twos(
94
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
95
+ PRIMARY KEY (id)
96
+ );
97
+ _SQL
98
+
99
+ execute <<_SQL
100
+ CREATE TABLE paint_colors(
101
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
102
+ non_poly_one_id INT,
103
+ PRIMARY KEY (id)
104
+ );
105
+ _SQL
106
+
107
+ execute <<_SQL
108
+ CREATE TABLE paint_textures(
109
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
110
+ non_poly_two_id INT,
111
+ PRIMARY KEY (id)
112
+ );
113
+ _SQL
114
+
115
+ execute <<_SQL
116
+ CREATE TABLE topics (
117
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
118
+ title VARCHAR(255) DEFAULT NULL,
119
+ author_name VARCHAR(255) DEFAULT NULL,
120
+ author_email_address VARCHAR(255) DEFAULT NULL,
121
+ written_on TIMESTAMP DEFAULT NULL,
122
+ bonus_time TIME DEFAULT NULL,
123
+ last_read DATE DEFAULT NULL,
124
+ content VARCHAR(3000),
125
+ approved SMALLINT DEFAULT 1,
126
+ replies_count INT DEFAULT 0,
127
+ parent_id INT DEFAULT NULL,
128
+ parent_title VARCHAR(255) DEFAULT NULL,
129
+ group VARCHAR(255) DEFAULT NULL,
130
+ type VARCHAR(255) DEFAULT NULL,
131
+ PRIMARY KEY (id)
132
+ );
133
+ _SQL
134
+
135
+ end
@@ -0,0 +1,138 @@
1
+ ActiveRecord::Schema.define do
2
+
3
+ execute "DROP TABLE COMMENTS" rescue nil
4
+ execute "DROP TABLE POSTS" rescue nil
5
+ execute "DROP TABLE ITEMS" rescue nil
6
+ execute "DROP TABLE TOPICS" rescue nil
7
+ execute "DROP TABLE fk_test_has_fk" rescue nil
8
+ execute "DROP TABLE fk_test_has_pk" rescue nil
9
+ execute "DROP TABLE CIRCLES" rescue nil
10
+ execute "DROP TABLE SQUARES" rescue nil
11
+ execute "DROP TABLE TRIANGLES" rescue nil
12
+ execute "DROP TABLE NON_POLY_ONES" rescue nil
13
+ execute "DROP TABLE NON_POLY_TWOS" rescue nil
14
+ execute "DROP TABLE PAINT_COLORS" rescue nil
15
+ execute "DROP TABLE PAINT_TEXTURES" rescue nil
16
+
17
+ execute <<_SQL
18
+ CREATE TABLE comments (
19
+ id SERIAL(100),
20
+ post_id INT DEFAULT NULL,
21
+ type VARCHAR(255) DEFAULT NULL,
22
+ body LVARCHAR(3000) DEFAULT NULL
23
+ );
24
+ _SQL
25
+
26
+ execute <<_SQL
27
+ CREATE TABLE posts (
28
+ id SERIAL(100),
29
+ author_id INT DEFAULT NULL,
30
+ title VARCHAR(255) DEFAULT NULL,
31
+ type VARCHAR(255) DEFAULT NULL,
32
+ body LVARCHAR(3000) DEFAULT NULL,
33
+ comments_count INT DEFAULT 0,
34
+ taggings_count INT DEFAULT 0,
35
+ PRIMARY KEY (id)
36
+ );
37
+
38
+ _SQL
39
+
40
+ execute <<_SQL
41
+ CREATE TABLE items (
42
+ id SERIAL(100),
43
+ name VARCHAR(255) DEFAULT NULL,
44
+ PRIMARY KEY (id)
45
+ );
46
+
47
+ _SQL
48
+
49
+ execute <<_SQL
50
+ CREATE TABLE circles (
51
+ id SERIAL(100),
52
+ PRIMARY KEY (id)
53
+ );
54
+ _SQL
55
+
56
+ execute <<_SQL
57
+ CREATE TABLE squares(
58
+ id SERIAL(100),
59
+ PRIMARY KEY (id)
60
+ );
61
+ _SQL
62
+
63
+ execute <<_SQL
64
+ CREATE TABLE triangles(
65
+ id SERIAL(100),
66
+ PRIMARY KEY (id)
67
+ );
68
+ _SQL
69
+
70
+ execute <<_SQL
71
+ CREATE TABLE non_poly_ones(
72
+ id SERIAL(100),
73
+ PRIMARY KEY (id)
74
+ );
75
+ _SQL
76
+
77
+ execute <<_SQL
78
+ CREATE TABLE non_poly_twos(
79
+ id SERIAL(100),
80
+ PRIMARY KEY (id)
81
+ );
82
+ _SQL
83
+
84
+ execute <<_SQL
85
+ CREATE TABLE paint_colors(
86
+ id SERIAL(100),
87
+ non_poly_one_id INT,
88
+ PRIMARY KEY (id)
89
+ );
90
+ _SQL
91
+
92
+ execute <<_SQL
93
+ CREATE TABLE paint_textures(
94
+ id SERIAL(100),
95
+ non_poly_two_id INT,
96
+ PRIMARY KEY (id)
97
+ );
98
+ _SQL
99
+
100
+ execute <<_SQL
101
+ CREATE TABLE topics (
102
+ id SERIAL(100),
103
+ title VARCHAR(255) DEFAULT NULL,
104
+ author_name VARCHAR(255) DEFAULT NULL,
105
+ author_email_address VARCHAR(255) DEFAULT NULL,
106
+ written_on DATETIME YEAR TO FRACTION(5) DEFAULT NULL,
107
+ bonus_time DATETIME YEAR TO FRACTION(5) DEFAULT NULL,
108
+ --bonus_time DATETIME HOUR TO SECOND DEFAULT NULL,
109
+ last_read DATE DEFAULT NULL,
110
+ content LVARCHAR(3000),
111
+ approved SMALLINT DEFAULT 1,
112
+ replies_count INT DEFAULT 0,
113
+ parent_id INT DEFAULT NULL,
114
+ parent_title VARCHAR(255) DEFAULT NULL,
115
+ group VARCHAR(255) DEFAULT NULL,
116
+ type VARCHAR(50) DEFAULT NULL,
117
+ PRIMARY KEY (id)
118
+ );
119
+
120
+ _SQL
121
+
122
+ execute <<_SQL
123
+ CREATE TABLE fk_test_has_pk (
124
+ id INT NOT NULL PRIMARY KEY
125
+ );
126
+
127
+ _SQL
128
+
129
+ execute <<_SQL
130
+ CREATE TABLE fk_test_has_fk (
131
+ id INT NOT NULL PRIMARY KEY,
132
+ fk_id INT NOT NULL,
133
+ FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id)
134
+ );
135
+
136
+ _SQL
137
+
138
+ end
@@ -0,0 +1,135 @@
1
+ ActiveRecord::Schema.define do
2
+
3
+ execute "DROP TABLE COMMENTS" rescue nil
4
+ execute "DROP TABLE POSTS" rescue nil
5
+ execute "DROP TABLE ITEMS" rescue nil
6
+ execute "DROP TABLE TOPICS" rescue nil
7
+ execute "DROP TABLE fk_test_has_fk" rescue nil
8
+ execute "DROP TABLE fk_test_has_pk" rescue nil
9
+ execute "DROP TABLE CIRCLES" rescue nil
10
+ execute "DROP TABLE SQUARES" rescue nil
11
+ execute "DROP TABLE TRIANGLES" rescue nil
12
+ execute "DROP TABLE NON_POLY_ONES" rescue nil
13
+ execute "DROP TABLE NON_POLY_TWOS" rescue nil
14
+ execute "DROP TABLE PAINT_COLORS" rescue nil
15
+ execute "DROP TABLE PAINT_TEXTURES" rescue nil
16
+
17
+ execute <<_SQL
18
+ CREATE TABLE comments (
19
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
20
+ post_id INT NOT NULL,
21
+ type VARCHAR(255) DEFAULT NULL,
22
+ body VARCHAR(3000)NOT NULL,
23
+ PRIMARY KEY (id)
24
+ );
25
+ _SQL
26
+
27
+ execute <<_SQL
28
+ CREATE TABLE posts (
29
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
30
+ author_id INT DEFAULT NULL,
31
+ title VARCHAR(255) NOT NULL,
32
+ type VARCHAR(255) DEFAULT NULL,
33
+ body VARCHAR(3000) NOT NULL,
34
+ comments_count integer DEFAULT 0,
35
+ taggings_count integer DEFAULT 0,
36
+ PRIMARY KEY (id)
37
+ );
38
+ _SQL
39
+
40
+ execute <<_SQL
41
+ CREATE TABLE fk_test_has_pk (
42
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
43
+ PRIMARY KEY (id)
44
+ );
45
+ _SQL
46
+
47
+ execute <<_SQL
48
+ CREATE TABLE fk_test_has_fk (
49
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
50
+ fk_id integer NOT NULL,
51
+ PRIMARY KEY (id),
52
+ FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id)
53
+ );
54
+ _SQL
55
+
56
+ execute <<_SQL
57
+ CREATE TABLE items (
58
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
59
+ name VARCHAR(255) DEFAULT NULL,
60
+ PRIMARY KEY (id)
61
+ );
62
+ _SQL
63
+
64
+ execute <<_SQL
65
+ CREATE TABLE circles (
66
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
67
+ PRIMARY KEY (id)
68
+ );
69
+ _SQL
70
+
71
+ execute <<_SQL
72
+ CREATE TABLE squares(
73
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
74
+ PRIMARY KEY (id)
75
+ );
76
+ _SQL
77
+
78
+ execute <<_SQL
79
+ CREATE TABLE triangles(
80
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
81
+ PRIMARY KEY (id)
82
+ );
83
+ _SQL
84
+
85
+ execute <<_SQL
86
+ CREATE TABLE non_poly_ones(
87
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
88
+ PRIMARY KEY (id)
89
+ );
90
+ _SQL
91
+
92
+ execute <<_SQL
93
+ CREATE TABLE non_poly_twos(
94
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
95
+ PRIMARY KEY (id)
96
+ );
97
+ _SQL
98
+
99
+ execute <<_SQL
100
+ CREATE TABLE paint_colors(
101
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
102
+ non_poly_one_id INT,
103
+ PRIMARY KEY (id)
104
+ );
105
+ _SQL
106
+
107
+ execute <<_SQL
108
+ CREATE TABLE paint_textures(
109
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 1),
110
+ non_poly_two_id INT,
111
+ PRIMARY KEY (id)
112
+ );
113
+ _SQL
114
+
115
+ execute <<_SQL
116
+ CREATE TABLE topics (
117
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
118
+ title VARCHAR(255) DEFAULT NULL,
119
+ author_name VARCHAR(255) DEFAULT NULL,
120
+ author_email_address VARCHAR(255) DEFAULT NULL,
121
+ written_on TIMESTAMP DEFAULT NULL,
122
+ bonus_time TIME DEFAULT NULL,
123
+ last_read DATE DEFAULT NULL,
124
+ content VARCHAR(3000),
125
+ approved SMALLINT DEFAULT 1,
126
+ replies_count INT DEFAULT 0,
127
+ parent_id INT DEFAULT NULL,
128
+ parent_title VARCHAR(255) DEFAULT NULL,
129
+ type VARCHAR(255) DEFAULT NULL,
130
+ group VARCHAR(255) DEFAULT NULL,
131
+ PRIMARY KEY (id)
132
+ );
133
+ _SQL
134
+
135
+ end