odbc-rails 1.3 → 1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/ChangeLog +18 -0
  2. data/NEWS +5 -0
  3. data/README +20 -7
  4. data/lib/active_record/connection_adapters/odbc_adapter.rb +254 -211
  5. data/lib/active_record/vendor/odbcext_informix.rb +17 -4
  6. data/lib/active_record/vendor/odbcext_ingres.rb +5 -5
  7. data/lib/active_record/vendor/odbcext_microsoftsqlserver.rb +35 -4
  8. data/lib/active_record/vendor/odbcext_mysql.rb +36 -8
  9. data/lib/active_record/vendor/odbcext_oracle.rb +4 -4
  10. data/lib/active_record/vendor/odbcext_postgresql.rb +8 -12
  11. data/lib/active_record/vendor/odbcext_progress.rb +3 -3
  12. data/lib/active_record/vendor/odbcext_progress89.rb +5 -4
  13. data/lib/active_record/vendor/odbcext_sybase.rb +6 -5
  14. data/lib/active_record/vendor/odbcext_virtuoso.rb +16 -3
  15. data/support/odbc_rails.diff +335 -266
  16. data/support/rake_fixes/README +6 -0
  17. data/support/rake_fixes/databases.dif +13 -0
  18. data/support/test/base_test.rb +333 -75
  19. data/support/test/migration_test.rb +430 -149
  20. data/test/connections/native_odbc/connection.rb +63 -44
  21. data/test/fixtures/db_definitions/db2.drop.sql +1 -0
  22. data/test/fixtures/db_definitions/db2.sql +9 -0
  23. data/test/fixtures/db_definitions/informix.drop.sql +1 -0
  24. data/test/fixtures/db_definitions/informix.sql +10 -0
  25. data/test/fixtures/db_definitions/ingres.drop.sql +2 -0
  26. data/test/fixtures/db_definitions/ingres.sql +9 -0
  27. data/test/fixtures/db_definitions/mysql.drop.sql +1 -0
  28. data/test/fixtures/db_definitions/mysql.sql +21 -12
  29. data/test/fixtures/db_definitions/oracle_odbc.drop.sql +4 -0
  30. data/test/fixtures/db_definitions/oracle_odbc.sql +29 -1
  31. data/test/fixtures/db_definitions/postgresql.drop.sql +3 -1
  32. data/test/fixtures/db_definitions/postgresql.sql +13 -3
  33. data/test/fixtures/db_definitions/progress.drop.sql +2 -0
  34. data/test/fixtures/db_definitions/progress.sql +11 -0
  35. data/test/fixtures/db_definitions/sqlserver.drop.sql +3 -0
  36. data/test/fixtures/db_definitions/sqlserver.sql +35 -0
  37. data/test/fixtures/db_definitions/sybase.drop.sql +2 -0
  38. data/test/fixtures/db_definitions/sybase.sql +16 -7
  39. data/test/fixtures/db_definitions/virtuoso.drop.sql +1 -0
  40. data/test/fixtures/db_definitions/virtuoso.sql +10 -0
  41. metadata +6 -3
@@ -1,5 +1,5 @@
1
1
  #
2
- # $Id: connection.rb,v 1.4 2006/10/09 07:25:07 source Exp $
2
+ # $Id: connection.rb,v 1.5 2007/02/27 11:00:49 source Exp $
3
3
  #
4
4
  # OpenLink ODBC Adapter for Ruby on Rails
5
5
  # Copyright (C) 2006 OpenLink Software
@@ -28,68 +28,87 @@ print "Using native ODBC\n"
28
28
  require_dependency 'fixtures/course'
29
29
  require 'logger'
30
30
 
31
- #ActiveRecord::Base.logger = Logger.new(STDOUT)
32
- #ActiveRecord::Base.logger = Logger.new("debug_odbc.log")
31
+ RAILS_DEFAULT_LOGGER = Logger.new("debug_odbc.log")
33
32
  #Logger level default is the lowest available, Logger::DEBUG
34
- #ActiveRecord::Base.logger.level = Logger::WARN
35
- ActiveRecord::Base.colorize_logging = false
33
+ #RAILS_DEFAULT_LOGGER.level = Logger::WARN
34
+ RAILS_DEFAULT_LOGGER.colorize_logging = false
35
+ ActiveRecord::Base.logger = RAILS_DEFAULT_LOGGER
36
36
 
37
- ActiveRecord::Base.establish_connection(
38
- :adapter => "odbc",
39
- :dsn => "a604-ora10-alice-testdb1",
40
- :username => "oracle",
41
- :password => "oracle",
42
- :trace => true
43
- )
37
+ ActiveRecord::Base.configurations = {
38
+ 'arunit' => {
39
+ :adapter => "odbc",
40
+ :dsn => "a609_ora10_alice_test1",
41
+ :username => "scott",
42
+ :password => "tiger",
43
+ :emulate_booleans => true,
44
+ :trace => false
45
+ },
46
+ 'arunit2' => {
47
+ :adapter => "odbc",
48
+ :dsn => "a609_ora10_alice_test1",
49
+ :username => "scott",
50
+ :password => "tiger",
51
+ :emulate_booleans => true,
52
+ :trace => false
53
+ }
54
+ }
44
55
 
45
- Course.establish_connection(
46
- :adapter => "odbc",
47
- :dsn => "a604-ora10-alice-testdb2",
48
- :username => "oracle",
49
- :password => "oracle",
50
- :trace => true
51
- )
56
+ ActiveRecord::Base.establish_connection 'arunit'
57
+ Course.establish_connection 'arunit2'
52
58
 
53
59
  ###########################################
54
- # Using Sybase
60
+ # Using DB2
55
61
 
56
62
  =begin
57
- ActiveRecord::Base.establish_connection(
63
+ ActiveRecord::Base.configurations = {
64
+ 'arunit' => {
58
65
  :adapter => "odbc",
59
- :dsn => "a609_syb15_trilby_testdb3",
60
- :username => "sa",
61
- :trace => true,
66
+ :dsn => "a610_db2_alice_rails1",
67
+ :username => "db2admin",
68
+ :password => "db2admin",
69
+ :trace => true,
62
70
  :convert_numeric_literals => true
63
- )
71
+ },
72
+ 'arunit2' => {
73
+ :adapter => "odbc",
74
+ :dsn => "a610_db2_alice_rails2",
75
+ :username => "db2admin",
76
+ :password => "db2admin",
77
+ :trace => true,
78
+ :convert_numeric_literals => true
79
+ }
80
+ }
64
81
 
65
- Course.establish_connection(
66
- :adapter => "odbc",
67
- :dsn => "a609_syb15_trilby_testdb4",
68
- :username => "sa",
69
- :trace => true,
70
- :convert_numeric_literals => true
71
- )
82
+ ActiveRecord::Base.establish_connection 'arunit'
83
+ Course.establish_connection 'arunit2'
72
84
  =end
73
85
 
74
86
  ###########################################
75
- # Using DB2
87
+ # Using Sybase 15
76
88
 
77
89
  =begin
78
- ActiveRecord::Base.establish_connection(
90
+ ActiveRecord::Base.configurations = {
91
+ 'arunit' => {
79
92
  :adapter => "odbc",
80
- :dsn => "a609_db2_alice_rails1",
81
- :username => "db2admin",
82
- :password => "db2admin",
93
+ :dsn => "a609_syb15_trilby_testdb3",
94
+ :username => "sa",
95
+ # :password => "",
83
96
  :trace => true,
84
97
  :convert_numeric_literals => true
85
- )
86
-
87
- Course.establish_connection(
98
+ },
99
+ 'arunit2' => {
88
100
  :adapter => "odbc",
89
- :dsn => "a609_db2_alice_rails2",
90
- :username => "db2admin",
91
- :password => "db2admin",
101
+ :dsn => "a609_syb15_trilby_testdb4",
102
+ :username => "sa",
103
+ # :password => "",
92
104
  :trace => true,
93
105
  :convert_numeric_literals => true
94
- )
106
+ }
107
+ }
108
+
109
+ ActiveRecord::Base.establish_connection 'arunit'
110
+ Course.establish_connection 'arunit2'
95
111
  =end
112
+
113
+ ###########################################
114
+ puts "Using DSN: #{ActiveRecord::Base.configurations["arunit"][:dsn]}"
@@ -28,3 +28,4 @@ DROP TABLE fk_test_has_pk;
28
28
  DROP TABLE fk_test_has_fk;
29
29
  DROP TABLE keyboards;
30
30
  DROP TABLE legacy_things;
31
+ DROP TABLE numeric_data;
@@ -215,3 +215,12 @@ CREATE TABLE legacy_things (
215
215
  version INT DEFAULT 0,
216
216
  PRIMARY KEY (id)
217
217
  );
218
+
219
+ CREATE TABLE numeric_data (
220
+ id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
221
+ bank_balance DECIMAL(10,2),
222
+ big_bank_balance DECIMAL(15,2),
223
+ world_population DECIMAL(10),
224
+ my_house_population DECIMAL(2),
225
+ decimal_number_with_default DECIMAL(3,2) DEFAULT 2.78
226
+ );
@@ -28,3 +28,4 @@ DROP TABLE fk_test_has_fk;
28
28
  DROP TABLE fk_test_has_pk;
29
29
  DROP TABLE keyboards;
30
30
  DROP TABLE legacy_things;
31
+ DROP TABLE numeric_data;
@@ -203,3 +203,13 @@ create table legacy_things (
203
203
  version int default 0,
204
204
  primary key (id)
205
205
  );
206
+
207
+ create table numeric_data (
208
+ id serial primary key,
209
+ bank_balance decimal(10,2),
210
+ big_bank_balance decimal(15,2),
211
+ world_population decimal(10,0),
212
+ my_house_population decimal(2,0),
213
+ decimal_number_with_default decimal(3,2) DEFAULT 2.78
214
+ );
215
+
@@ -28,6 +28,7 @@ DROP TABLE fk_test_has_fk;
28
28
  DROP TABLE fk_test_has_pk;
29
29
  DROP TABLE keyboards;
30
30
  DROP TABLE legacy_things;
31
+ DROP TABLE numeric_data;
31
32
 
32
33
  drop sequence accounts_seq;
33
34
  drop sequence funny_jokes_seq;
@@ -59,4 +60,5 @@ drop sequence fk_test_has_pk_seq;
59
60
  drop sequence fk_test_has_fk_seq;
60
61
  drop sequence keyboards_seq;
61
62
  drop sequence legacy_things_seq;
63
+ drop sequence numeric_data_seq;
62
64
 
@@ -230,3 +230,12 @@ CREATE TABLE legacy_things (
230
230
  ) WITH PAGE_SIZE=8192;
231
231
  CREATE SEQUENCE legacy_things_seq MINVALUE 10000;
232
232
 
233
+ CREATE TABLE numeric_data (
234
+ id INTEGER PRIMARY KEY NOT NULL,
235
+ bank_balance decimal(10,2),
236
+ big_bank_balance decimal(15,2),
237
+ world_population decimal(10,0),
238
+ my_house_population decimal(2,0),
239
+ decimal_number_with_default decimal(3,2) DEFAULT 2.78
240
+ ) WITH PAGE_SIZE=8192;
241
+ CREATE SEQUENCE numeric_data_seq MINVALUE 10000;
@@ -28,3 +28,4 @@ DROP TABLE fk_test_has_fk;
28
28
  DROP TABLE fk_test_has_pk;
29
29
  DROP TABLE keyboards;
30
30
  DROP TABLE legacy_things;
31
+ DROP TABLE numeric_data;
@@ -37,7 +37,7 @@ CREATE TABLE `topics` (
37
37
  `parent_id` int(11) default NULL,
38
38
  `type` varchar(50) default NULL,
39
39
  PRIMARY KEY (`id`)
40
- ) TYPE=InnoDB;
40
+ ) TYPE=InnoDB DEFAULT CHARSET=utf8;
41
41
 
42
42
  CREATE TABLE `developers` (
43
43
  `id` int(11) NOT NULL auto_increment,
@@ -106,7 +106,7 @@ CREATE TABLE `auto_id_tests` (
106
106
  ) TYPE=InnoDB;
107
107
 
108
108
  CREATE TABLE `entrants` (
109
- `id` INTEGER NOT NULL PRIMARY KEY,
109
+ `id` INTEGER NOT NULL auto_increment PRIMARY KEY,
110
110
  `name` VARCHAR(255) NOT NULL,
111
111
  `course_id` INTEGER NOT NULL
112
112
  );
@@ -137,7 +137,7 @@ CREATE TABLE `people` (
137
137
  ) TYPE=InnoDB;
138
138
 
139
139
  CREATE TABLE `readers` (
140
- `id` int(11) NOT NULL PRIMARY KEY,
140
+ `id` int(11) NOT NULL auto_increment PRIMARY KEY,
141
141
  `post_id` INTEGER NOT NULL,
142
142
  `person_id` INTEGER NOT NULL
143
143
  ) TYPE=InnoDB;
@@ -149,28 +149,28 @@ CREATE TABLE `binaries` (
149
149
  ) TYPE=InnoDB;
150
150
 
151
151
  CREATE TABLE `computers` (
152
- `id` INTEGER NOT NULL PRIMARY KEY,
152
+ `id` INTEGER NOT NULL auto_increment PRIMARY KEY,
153
153
  `developer` INTEGER NOT NULL,
154
154
  `extendedWarranty` INTEGER NOT NULL
155
155
  ) TYPE=InnoDB;
156
156
 
157
157
  CREATE TABLE `posts` (
158
- `id` INTEGER NOT NULL PRIMARY KEY,
158
+ `id` INTEGER NOT NULL auto_increment PRIMARY KEY,
159
159
  `author_id` INTEGER,
160
160
  `title` VARCHAR(255) NOT NULL,
161
161
  `body` TEXT NOT NULL,
162
- `type` VARCHAR(255) NOT NULL
162
+ `type` VARCHAR(255) default NULL
163
163
  ) TYPE=InnoDB;
164
164
 
165
165
  CREATE TABLE `comments` (
166
- `id` INTEGER NOT NULL PRIMARY KEY,
166
+ `id` INTEGER NOT NULL auto_increment PRIMARY KEY,
167
167
  `post_id` INTEGER NOT NULL,
168
168
  `body` TEXT NOT NULL,
169
- `type` VARCHAR(255) NOT NULL
169
+ `type` VARCHAR(255) default NULL
170
170
  ) TYPE=InnoDB;
171
171
 
172
172
  CREATE TABLE `authors` (
173
- `id` INTEGER NOT NULL PRIMARY KEY,
173
+ `id` INTEGER NOT NULL auto_increment PRIMARY KEY,
174
174
  `name` VARCHAR(255) NOT NULL
175
175
  ) TYPE=InnoDB;
176
176
 
@@ -184,7 +184,7 @@ CREATE TABLE `tasks` (
184
184
  CREATE TABLE `categories` (
185
185
  `id` int(11) NOT NULL auto_increment,
186
186
  `name` VARCHAR(255) NOT NULL,
187
- `type` VARCHAR(255) NOT NULL,
187
+ `type` VARCHAR(255) default NULL,
188
188
  PRIMARY KEY (`id`)
189
189
  ) TYPE=InnoDB;
190
190
 
@@ -194,11 +194,11 @@ CREATE TABLE `categories_posts` (
194
194
  ) TYPE=InnoDB;
195
195
 
196
196
  CREATE TABLE `fk_test_has_pk` (
197
- `id` INTEGER NOT NULL PRIMARY KEY
197
+ `id` INTEGER NOT NULL auto_increment PRIMARY KEY
198
198
  ) TYPE=InnoDB;
199
199
 
200
200
  CREATE TABLE `fk_test_has_fk` (
201
- `id` INTEGER NOT NULL PRIMARY KEY,
201
+ `id` INTEGER NOT NULL auto_increment PRIMARY KEY,
202
202
  `fk_id` INTEGER NOT NULL,
203
203
 
204
204
  FOREIGN KEY (`fk_id`) REFERENCES `fk_test_has_pk`(`id`)
@@ -217,3 +217,12 @@ CREATE TABLE `legacy_things` (
217
217
  `version` int(11) NOT NULL default 0,
218
218
  PRIMARY KEY (`id`)
219
219
  ) TYPE=InnoDB;
220
+
221
+ CREATE TABLE `numeric_data` (
222
+ `id` INTEGER NOT NULL auto_increment PRIMARY KEY,
223
+ `bank_balance` decimal(10,2),
224
+ `big_bank_balance` decimal(15,2),
225
+ `world_population` decimal(10),
226
+ `my_house_population` decimal(2),
227
+ `decimal_number_with_default` decimal(3,2) DEFAULT 2.78
228
+ ) TYPE=InnoDB;
@@ -12,6 +12,7 @@ drop table orders;
12
12
  drop table movies;
13
13
  drop table subscribers;
14
14
  drop table booleantests;
15
+ drop table defaults;
15
16
  drop table auto_id_tests;
16
17
  drop table entrants;
17
18
  drop table colnametests;
@@ -29,6 +30,7 @@ drop table fk_test_has_pk;
29
30
  drop table fk_test_has_fk;
30
31
  drop table keyboards;
31
32
  drop table legacy_things;
33
+ drop table numeric_data;
32
34
  drop table test_oracle_defaults;
33
35
 
34
36
  drop sequence accounts_seq;
@@ -43,6 +45,7 @@ drop sequence orders_seq;
43
45
  drop sequence movies_seq;
44
46
  drop sequence subscribers_seq;
45
47
  drop sequence booleantests_seq;
48
+ drop sequence defaults_seq;
46
49
  drop sequence auto_id_tests_seq;
47
50
  drop sequence entrants_seq;
48
51
  drop sequence colnametests_seq;
@@ -61,4 +64,5 @@ drop sequence fk_test_has_pk_seq;
61
64
  drop sequence fk_test_has_fk_seq;
62
65
  drop sequence keyboards_seq;
63
66
  drop sequence legacy_things_seq;
67
+ drop sequence numeric_data_seq;
64
68
  drop sequence test_oracle_defaults_seq;
@@ -37,7 +37,7 @@ create table topics (
37
37
  bonus_time timestamp default null,
38
38
  last_read timestamp default null,
39
39
  content varchar(4000),
40
- approved number(10) default 1,
40
+ approved number(1) default 1,
41
41
  replies_count number(10) default 0,
42
42
  parent_id number(10) references topics initially deferred disable,
43
43
  type varchar(50) default null,
@@ -115,6 +115,23 @@ create table booleantests (
115
115
  );
116
116
  create sequence booleantests_seq minvalue 10000;
117
117
 
118
+ create table defaults (
119
+ id number(10) not null,
120
+ modified_date date default sysdate,
121
+ modified_date_function date default sysdate,
122
+ fixed_date date default to_date('2004-01-01', 'YYYY-MM-DD'),
123
+ modified_time date default sysdate,
124
+ modified_time_function date default sysdate,
125
+ fixed_time date default TO_DATE('2004-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'),
126
+ char1 varchar2(1) default 'Y',
127
+ char2 varchar2(50) default 'a varchar field',
128
+ char3 clob default 'a text field',
129
+ positive_integer number(10) default 1,
130
+ negative_integer number(10) default -1,
131
+ decimal_number number(3,2) default 2.78
132
+ );
133
+ create sequence defaults_seq minvalue 10000;
134
+
118
135
  create table auto_id_tests (
119
136
  auto_id number(10) not null,
120
137
  value number(10) default null,
@@ -255,3 +272,14 @@ create table legacy_things (
255
272
  version number(10) default 0
256
273
  );
257
274
  create sequence legacy_things_seq minvalue 10000;
275
+
276
+ create table numeric_data (
277
+ id number(10) not null primary key,
278
+ bank_balance decimal(10,2),
279
+ big_bank_balance decimal(15,2),
280
+ world_population decimal(10),
281
+ my_house_population decimal(2),
282
+ decimal_number_with_default decimal(3,2) default 2.78
283
+ );
284
+ create sequence numeric_data_seq minvalue 10000;
285
+
@@ -1,5 +1,5 @@
1
- DROP SEQUENCE accounts_id_seq;
2
1
  DROP TABLE accounts;
2
+ DROP SEQUENCE accounts_id_seq;
3
3
  DROP TABLE funny_jokes;
4
4
  DROP TABLE companies;
5
5
  DROP SEQUENCE companies_nonstd_seq;
@@ -32,3 +32,5 @@ DROP TABLE fk_test_has_pk;
32
32
  DROP TABLE geometrics;
33
33
  DROP TABLE keyboards;
34
34
  DROP TABLE legacy_things;
35
+ DROP TABLE numeric_data;
36
+ DROP TABLE column_data;
@@ -118,7 +118,8 @@ CREATE TABLE defaults (
118
118
  char2 character varying(50) default 'a varchar field',
119
119
  char3 text default 'a text field',
120
120
  positive_integer integer default 1,
121
- negative_integer integer default -1
121
+ negative_integer integer default -1,
122
+ decimal_number decimal(3,2) default 2.78
122
123
  );
123
124
 
124
125
  CREATE TABLE auto_id_tests (
@@ -129,8 +130,8 @@ CREATE TABLE auto_id_tests (
129
130
 
130
131
  CREATE TABLE entrants (
131
132
  id serial,
132
- name text,
133
- course_id integer
133
+ name text not null,
134
+ course_id integer not null
134
135
  );
135
136
 
136
137
  CREATE TABLE colnametests (
@@ -246,3 +247,12 @@ CREATE TABLE legacy_things (
246
247
  tps_report_number integer,
247
248
  version integer default 0
248
249
  );
250
+
251
+ CREATE TABLE numeric_data (
252
+ id serial primary key,
253
+ bank_balance decimal(10,2),
254
+ big_bank_balance decimal(15,2),
255
+ world_population decimal(10),
256
+ my_house_population decimal(2),
257
+ decimal_number_with_default decimal(3,2) default 2.78
258
+ );
@@ -28,6 +28,7 @@ drop table readers;
28
28
  drop table subscribers;
29
29
  drop table tasks;
30
30
  drop table topics;
31
+ drop table numeric_data;
31
32
 
32
33
  drop sequence accounts_seq;
33
34
  drop sequence authors_seq;
@@ -59,3 +60,4 @@ drop sequence readers_seq;
59
60
  drop sequence subscribers_seq;
60
61
  drop sequence tasks_seq;
61
62
  drop sequence topics_seq;
63
+ drop sequence numeric_data_seq;