ibm_db 1.1.1-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/CHANGES +155 -0
  2. data/LICENSE +18 -0
  3. data/MANIFEST +14 -0
  4. data/README +274 -0
  5. data/ext/Makefile.nt32 +181 -0
  6. data/ext/extconf.rb +58 -0
  7. data/ext/ibm_db.c +6553 -0
  8. data/ext/ruby_ibm_db.h +214 -0
  9. data/init.rb +42 -0
  10. data/lib/IBM_DB.rb +2 -0
  11. data/lib/active_record/connection_adapters/ibm_db_adapter.rb +2218 -0
  12. data/lib/active_record/vendor/db2-i5-zOS.yaml +328 -0
  13. data/lib/mswin32/ibm_db.so +0 -0
  14. data/test/cases/adapter_test.rb +180 -0
  15. data/test/cases/associations/cascaded_eager_loading_test.rb +133 -0
  16. data/test/cases/associations/eager_test.rb +842 -0
  17. data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +874 -0
  18. data/test/cases/associations/has_many_through_associations_test.rb +281 -0
  19. data/test/cases/associations/join_model_test.rb +801 -0
  20. data/test/cases/attribute_methods_test.rb +312 -0
  21. data/test/cases/base_test.rb +2114 -0
  22. data/test/cases/calculations_test.rb +346 -0
  23. data/test/cases/finder_test.rb +1092 -0
  24. data/test/cases/fixtures_test.rb +660 -0
  25. data/test/cases/migration_test.rb +1618 -0
  26. data/test/cases/schema_dumper_test.rb +197 -0
  27. data/test/cases/validations_test.rb +1604 -0
  28. data/test/connections/native_ibm_db/connection.rb +40 -0
  29. data/test/ibm_db_test.rb +25 -0
  30. data/test/models/warehouse_thing.rb +5 -0
  31. data/test/schema/i5/ibm_db_specific_schema.rb +134 -0
  32. data/test/schema/ids/ibm_db_specific_schema.rb +137 -0
  33. data/test/schema/luw/ibm_db_specific_schema.rb +134 -0
  34. data/test/schema/schema.rb +499 -0
  35. data/test/schema/zOS/ibm_db_specific_schema.rb +205 -0
  36. metadata +115 -0
@@ -0,0 +1,40 @@
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
+ },
23
+ 'arunit2' => {
24
+ :adapter => 'ibm_db',
25
+ :username => 'db2user',
26
+ :password => 'secret',
27
+ :host => 'bilbao',
28
+ :port => '50000',
29
+ :schema => 'rails123',
30
+ :account => 'tester',
31
+ :app_user => 'tester_11',
32
+ :application => 'rails_tests',
33
+ :workstation => 'auckland',
34
+ :start_id => 100,
35
+ :database => 'ARUNIT2'
36
+ }
37
+ }
38
+
39
+ ActiveRecord::Base.establish_connection 'arunit'
40
+ 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,134 @@
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
+ PRIMARY KEY (id)
131
+ );
132
+ _SQL
133
+
134
+ end
@@ -0,0 +1,137 @@
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
+ type VARCHAR(50) DEFAULT NULL,
116
+ PRIMARY KEY (id)
117
+ );
118
+
119
+ _SQL
120
+
121
+ execute <<_SQL
122
+ CREATE TABLE fk_test_has_pk (
123
+ id INT NOT NULL PRIMARY KEY
124
+ );
125
+
126
+ _SQL
127
+
128
+ execute <<_SQL
129
+ CREATE TABLE fk_test_has_fk (
130
+ id INT NOT NULL PRIMARY KEY,
131
+ fk_id INT NOT NULL,
132
+ FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id)
133
+ );
134
+
135
+ _SQL
136
+
137
+ end
@@ -0,0 +1,134 @@
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
+ PRIMARY KEY (id)
131
+ );
132
+ _SQL
133
+
134
+ end