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,328 @@
1
+ add : ADD
2
+ after : AFTER
3
+ alias : ALIAS
4
+ all : ALL
5
+ allocate : ALLOCATE
6
+ allow : ALLOW
7
+ alter : ALTER
8
+ and : AND
9
+ any : ANY
10
+ as : AS
11
+ asensitive : ASENSITIVE
12
+ associate : ASSOCIATE
13
+ asutime : ASUTIME
14
+ audit : AUDIT
15
+ authorization : AUTHORIZATION
16
+ aux : AUX
17
+ auxiliary : AUXILIARY
18
+ before : BEFORE
19
+ begin : BEGIN
20
+ between : BETWEEN
21
+ binary : BINARY
22
+ bufferpool : BUFFERPOOL
23
+ by : BY
24
+ cache : CACHE
25
+ call : CALL
26
+ called : CALLED
27
+ cardinality : CARDINALITY
28
+ capture : CAPTURE
29
+ cascaded : CASCADED
30
+ case : CASE
31
+ cast : CAST
32
+ ccsid : CCSID
33
+ char : CHAR
34
+ character : CHARACTER
35
+ check : CHECK
36
+ close : CLOSE
37
+ cluster : CLUSTER
38
+ collection : COLLECTION
39
+ collid : COLLID
40
+ column : COLUMN
41
+ comment : COMMENT
42
+ commit : COMMIT
43
+ concat : CONCAT
44
+ condition : CONDITION
45
+ connect : CONNECT
46
+ connection : CONNECTION
47
+ constraint : CONSTRAINT
48
+ contains : CONTAINS
49
+ continue : CONTINUE
50
+ count : COUNT
51
+ count_big : COUNT_BIG
52
+ create : CREATE
53
+ cross : CROSS
54
+ current : CURRENT
55
+ current_date : CURRENT_DATE
56
+ current_lc_ctype : CURRENT_LC_CTYPE
57
+ current_path : CURRENT_PATH
58
+ current_time : CURRENT_TIME
59
+ current_timestamp : CURRENT_TIMESTAMP
60
+ current_timezone : CURRENT_TIMEZONE
61
+ current_user : CURRENT_USER
62
+ cursor : CURSOR
63
+ cycle : CYCLE
64
+ data : DATA
65
+ database : DATABASE
66
+ day : DAY
67
+ days : DAYS
68
+ dbinfo : DBINFO
69
+ db2genrl : DB2GENRL
70
+ db2sql : DB2SQL
71
+ declare : DECLARE
72
+ default : DEFAULT
73
+ defaults : DEFAULTS
74
+ definition : DEFINITION
75
+ delete : DELETE
76
+ descriptor : DESCRIPTOR
77
+ deterministic : DETERMINISTIC
78
+ disallow : DISALLOW
79
+ disconnect : DISCONNECT
80
+ distinct : DISTINCT
81
+ do : DO
82
+ double : DOUBLE
83
+ drop : DROP
84
+ dssize : DSSIZE
85
+ dynamic : DYNAMIC
86
+ each : EACH
87
+ editproc : EDITPROC
88
+ else : ELSE
89
+ elseif : ELSEIF
90
+ encoding : ENCODING
91
+ encryption : ENCRYPTION
92
+ end : END
93
+ ending : ENDING
94
+ end-exec : END-EXEC
95
+ erase : ERASE
96
+ escape : ESCAPE
97
+ except : EXCEPT
98
+ excluding : EXCLUDING
99
+ exception : EXCEPTION
100
+ execute : EXECUTE
101
+ exists : EXISTS
102
+ exit : EXIT
103
+ explain : EXPLAIN
104
+ external : EXTERNAL
105
+ fenced : FENCED
106
+ fetch : FETCH
107
+ fieldproc : FIELDPROC
108
+ file : FILE
109
+ final : FINAL
110
+ for : FOR
111
+ foreign : FOREIGN
112
+ free : FREE
113
+ from : FROM
114
+ full : FULL
115
+ function : FUNCTION
116
+ general : GENERAL
117
+ generated : GENERATED
118
+ get : GET
119
+ global : GLOBAL
120
+ go : GO
121
+ goto : GOTO
122
+ grant : GRANT
123
+ graphic : GRAPHIC
124
+ group : GROUP
125
+ handler : HANDLER
126
+ having : HAVING
127
+ hold : HOLD
128
+ hour : HOUR
129
+ hours : HOURS
130
+ identity : IDENTITY
131
+ if : IF
132
+ immediate : IMMEDIATE
133
+ in : IN
134
+ including : INCLUDING
135
+ inclusive : INCLUSIVE
136
+ increment : INCREMENT
137
+ index : INDEX
138
+ indicator : INDICATOR
139
+ inherit : INHERIT
140
+ inner : INNER
141
+ inout : INOUT
142
+ insensitive : INSENSITIVE
143
+ insert : INSERT
144
+ integrity : INTEGRITY
145
+ into : INTO
146
+ is : IS
147
+ isobid : ISOBID
148
+ isolation : ISOLATION
149
+ iterate : ITERATE
150
+ jar : JAR
151
+ java : JAVA
152
+ join : JOIN
153
+ key : KEY
154
+ label : LABEL
155
+ language : LANGUAGE
156
+ lc_ctype : LC_CTYPE
157
+ leave : LEAVE
158
+ left : LEFT
159
+ like : LIKE
160
+ linktype : LINKTYPE
161
+ local : LOCAL
162
+ locale : LOCALE
163
+ locator : LOCATOR
164
+ locators : LOCATORS
165
+ lock : LOCK
166
+ lockmax : LOCKMAX
167
+ locksize : LOCKSIZE
168
+ long : LONG
169
+ loop : LOOP
170
+ maintained : MAINTAINED
171
+ materialized : MATERIALIZED
172
+ maxvalue : MAXVALUE
173
+ microsecond : MICROSECOND
174
+ microseconds : MICROSECONDS
175
+ minute : MINUTE
176
+ minutes : MINUTES
177
+ minvalue : MINVALUE
178
+ mode : MODE
179
+ modifies : MODIFIES
180
+ month : MONTH
181
+ months : MONTHS
182
+ new : NEW
183
+ new_table : NEW_TABLE
184
+ nextval : NEXTVAL
185
+ no : NO
186
+ nocache : NOCACHE
187
+ nocycle : NOCYCLE
188
+ nodename : NODENAME
189
+ nodenumber : NODENUMBER
190
+ nomaxvalue : NOMAXVALUE
191
+ nominvalue : NOMINVALUE
192
+ none : NONE
193
+ noorder : NOORDER
194
+ not : NOT
195
+ null : NULL
196
+ nulls : NULLS
197
+ numparts : NUMPARTS
198
+ obid : OBID
199
+ of : OF
200
+ old : OLD
201
+ old_table : OLD_TABLE
202
+ on : ON
203
+ open : OPEN
204
+ optimization : OPTIMIZATION
205
+ optimize : OPTIMIZE
206
+ option : OPTION
207
+ or : OR
208
+ order : ORDER
209
+ out : OUT
210
+ outer : OUTER
211
+ overriding : OVERRIDING
212
+ package : PACKAGE
213
+ parameter : PARAMETER
214
+ part : PART
215
+ padded : PADDED
216
+ partition : PARTITION
217
+ partitioned : PARTITIONED
218
+ partitioning : PARTITIONING
219
+ path : PATH
220
+ piecesize : PIECESIZE
221
+ plan : PLAN
222
+ position : POSITION
223
+ precision : PRECISION
224
+ prepare : PREPARE
225
+ prevval : PREVVAL
226
+ primary : PRIMARY
227
+ priqty : PRIQTY
228
+ privileges : PRIVILEGES
229
+ procedure : PROCEDURE
230
+ program : PROGRAM
231
+ psid : PSID
232
+ query : QUERY
233
+ queryno : QUERYNO
234
+ read : READ
235
+ reads : READS
236
+ recovery : RECOVERY
237
+ references : REFERENCES
238
+ referencing : REFERENCING
239
+ refresh : REFRESH
240
+ resignal : RESIGNAL
241
+ release : RELEASE
242
+ rename : RENAME
243
+ repeat : REPEAT
244
+ reset : RESET
245
+ resignal : RESIGNAL
246
+ restart : RESTART
247
+ restrict : RESTRICT
248
+ result : RESULT
249
+ result_set_locator : RESULT_SET_LOCATOR
250
+ return : RETURN
251
+ returns : RETURNS
252
+ revoke : REVOKE
253
+ right : RIGHT
254
+ rollback : ROLLBACK
255
+ routine : ROUTINE
256
+ row : ROW
257
+ rows : ROWS
258
+ rowset : ROWSET
259
+ rrn : RRN
260
+ run : RUN
261
+ savepoint : SAVEPOINT
262
+ schema : SCHEMA
263
+ scratchpad : SCRATCHPAD
264
+ second : SECOND
265
+ seconds : SECONDS
266
+ secqty : SECQTY
267
+ security : SECURITY
268
+ sequence : SEQUENCE
269
+ select : SELECT
270
+ sensitive : SENSITIVE
271
+ set : SET
272
+ signal : SIGNAL
273
+ simple : SIMPLE
274
+ some : SOME
275
+ source : SOURCE
276
+ specific : SPECIFIC
277
+ sql : SQL
278
+ sqlid : SQLID
279
+ standard : STANDARD
280
+ start : START
281
+ static : STATIC
282
+ stay : STAY
283
+ stogroup : STOGROUP
284
+ stores : STORES
285
+ style : STYLE
286
+ substring : SUBSTRING
287
+ summary : SUMMARY
288
+ synonym : SYNONYM
289
+ sysfun : SYSFUN
290
+ sysibm : SYSIBM
291
+ sysproc : SYSPROC
292
+ system : SYSTEM
293
+ table : TABLE
294
+ tablespace : TABLESPACE
295
+ then : THEN
296
+ to : TO
297
+ transaction : TRANSACTION
298
+ trigger : TRIGGER
299
+ trim : TRIM
300
+ type : TYPE
301
+ undo : UNDO
302
+ union : UNION
303
+ unique : UNIQUE
304
+ until : UNTIL
305
+ update : UPDATE
306
+ user : USER
307
+ usage : USAGE
308
+ user : USER
309
+ using : USING
310
+ validproc : VALIDPROC
311
+ value : VALUE
312
+ values : VALUES
313
+ variable : VARIABLE
314
+ variant : VARIANT
315
+ vcat : VCAT
316
+ view : VIEW
317
+ volatile : VOLATILE
318
+ volumes : VOLUMES
319
+ when : WHEN
320
+ whenever : WHENEVER
321
+ where : WHERE
322
+ while : WHILE
323
+ with : WITH
324
+ wlm : WLM
325
+ write : WRITE
326
+ xmlelement : XMLELEMENT
327
+ year : YEAR
328
+ years : YEARS
Binary file
@@ -0,0 +1,180 @@
1
+ require "cases/helper"
2
+
3
+ class AdapterTest < ActiveRecord::TestCase
4
+ def setup
5
+ @connection = ActiveRecord::Base.connection
6
+ end
7
+
8
+ if current_adapter?(:IBM_DBAdapter)
9
+ def test_a_connection_attributes
10
+ if @connection.servertype.class.name.include?('::IBM_IDS')
11
+ return
12
+ end
13
+ if @connection.respond_to?(:schema)
14
+ previous_schema = ActiveRecord::Base.connection.schema
15
+ ActiveRecord::Base.connection.schema = 'SYSCAT'
16
+ assert_equal 'SYSCAT', ActiveRecord::Base.connection.schema
17
+ ActiveRecord::Base.connection.schema = previous_schema
18
+ else
19
+ warn "#{@connection.class} does not support client connection attribute schema_name"
20
+ end
21
+
22
+ if @connection.respond_to?(:app_user)
23
+ ActiveRecord::Base.connection.app_user = 'new_user'
24
+ assert_equal 'new_user', ActiveRecord::Base.connection.app_user
25
+ else
26
+ warn "#{@connection.class} does not support client connection attribute SQL_ATTR_INFO_USER"
27
+ end
28
+
29
+ if @connection.respond_to?(:account)
30
+ ActiveRecord::Base.connection.account = 'new_acct'
31
+ assert_equal 'new_acct', ActiveRecord::Base.connection.account
32
+ else
33
+ warn "#{@connection.class} does not support client connection attribute SQL_ATTR_INFO_ACCTSTR"
34
+ end
35
+
36
+ if @connection.respond_to?(:application)
37
+ ActiveRecord::Base.connection.application = 'new_app'
38
+ assert_equal 'new_app', ActiveRecord::Base.connection.application
39
+ else
40
+ warn "#{@connection.class} does not support client connection attribute SQL_ATTR_INFO_APPLNAME"
41
+ end
42
+
43
+ if @connection.respond_to?(:workstation)
44
+ ActiveRecord::Base.connection.workstation = 'new_wrkst'
45
+ assert_equal 'new_wrkst', ActiveRecord::Base.connection.workstation
46
+ else
47
+ warn "#{@connection.class} does not support client connection attribute SQL_ATTR_INFO_WRKSTNNAME"
48
+ end
49
+ end
50
+ end
51
+
52
+ def test_tables
53
+ tables = @connection.tables
54
+ assert tables.include?("accounts")
55
+ assert tables.include?("authors")
56
+ assert tables.include?("tasks")
57
+ assert tables.include?("topics")
58
+ end
59
+
60
+ def test_table_exists?
61
+ assert @connection.table_exists?("accounts")
62
+ assert !@connection.table_exists?("nonexistingtable")
63
+ end
64
+
65
+ def test_indexes
66
+ idx_name = "accounts_idx"
67
+
68
+ if @connection.respond_to?(:indexes)
69
+ indexes = @connection.indexes("accounts")
70
+ assert indexes.empty?
71
+
72
+ @connection.add_index :accounts, :firm_id, :name => idx_name
73
+ indexes = @connection.indexes("accounts")
74
+ assert_equal "accounts", indexes.first.table
75
+ # OpenBase does not have the concept of a named index
76
+ # Indexes are merely properties of columns.
77
+ assert_equal idx_name, indexes.first.name unless current_adapter?(:OpenBaseAdapter)
78
+ assert !indexes.first.unique
79
+ assert_equal ["firm_id"], indexes.first.columns
80
+ else
81
+ warn "#{@connection.class} does not respond to #indexes"
82
+ end
83
+
84
+ ensure
85
+ @connection.remove_index(:accounts, :name => idx_name) rescue nil
86
+ end
87
+
88
+ def test_current_database
89
+ if @connection.respond_to?(:current_database)
90
+ assert_equal ENV['ARUNIT_DB_NAME'] || "activerecord_unittest", @connection.current_database
91
+ end
92
+ end
93
+
94
+ if current_adapter?(:MysqlAdapter)
95
+ def test_charset
96
+ assert_not_nil @connection.charset
97
+ assert_not_equal 'character_set_database', @connection.charset
98
+ assert_equal @connection.show_variable('character_set_database'), @connection.charset
99
+ end
100
+
101
+ def test_collation
102
+ assert_not_nil @connection.collation
103
+ assert_not_equal 'collation_database', @connection.collation
104
+ assert_equal @connection.show_variable('collation_database'), @connection.collation
105
+ end
106
+
107
+ def test_show_nonexistent_variable_returns_nil
108
+ assert_nil @connection.show_variable('foo_bar_baz')
109
+ end
110
+ end
111
+
112
+ if current_adapter?(:PostgreSQLAdapter)
113
+ def test_encoding
114
+ assert_not_nil @connection.encoding
115
+ end
116
+ end
117
+
118
+ def test_table_alias
119
+ def @connection.test_table_alias_length() 10; end
120
+ class << @connection
121
+ alias_method :old_table_alias_length, :table_alias_length
122
+ alias_method :table_alias_length, :test_table_alias_length
123
+ end
124
+
125
+ assert_equal 'posts', @connection.table_alias_for('posts')
126
+ assert_equal 'posts_comm', @connection.table_alias_for('posts_comments')
127
+ assert_equal 'dbo_posts', @connection.table_alias_for('dbo.posts')
128
+
129
+ class << @connection
130
+ remove_method :table_alias_length
131
+ alias_method :table_alias_length, :old_table_alias_length
132
+ end
133
+ end
134
+
135
+ # test resetting sequences in odd tables in postgreSQL
136
+ if ActiveRecord::Base.connection.respond_to?(:reset_pk_sequence!)
137
+ require 'models/movie'
138
+ require 'models/subscriber'
139
+
140
+ def test_reset_empty_table_with_custom_pk
141
+ Movie.delete_all
142
+ Movie.connection.reset_pk_sequence! 'movies'
143
+ assert_equal 1, Movie.create(:name => 'fight club').id
144
+ end
145
+
146
+ if ActiveRecord::Base.connection.adapter_name != "FrontBase"
147
+ def test_reset_table_with_non_integer_pk
148
+ Subscriber.delete_all
149
+ Subscriber.connection.reset_pk_sequence! 'subscribers'
150
+ sub = Subscriber.new(:name => 'robert drake')
151
+ sub.id = 'bob drake'
152
+ assert_nothing_raised { sub.save! }
153
+ end
154
+ end
155
+ end
156
+
157
+ unless current_adapter?(:IBM_DBAdapter)
158
+ def test_add_limit_offset_should_sanitize_sql_injection_for_limit_without_comas
159
+ sql_inject = "1 select * from schema"
160
+ assert_equal " LIMIT 1", @connection.add_limit_offset!("", :limit=>sql_inject)
161
+ if current_adapter?(:MysqlAdapter)
162
+ assert_equal " LIMIT 7, 1", @connection.add_limit_offset!("", :limit=>sql_inject, :offset=>7)
163
+ else
164
+ assert_equal " LIMIT 1 OFFSET 7", @connection.add_limit_offset!("", :limit=>sql_inject, :offset=>7)
165
+ end
166
+ end
167
+
168
+ def test_add_limit_offset_should_sanitize_sql_injection_for_limit_with_comas
169
+ sql_inject = "1, 7 procedure help()"
170
+ if current_adapter?(:MysqlAdapter)
171
+ assert_equal " LIMIT 1,7", @connection.add_limit_offset!("", :limit=>sql_inject)
172
+ assert_equal " LIMIT 7, 1", @connection.add_limit_offset!("", :limit=>sql_inject, :offset=>7)
173
+ else
174
+ assert_equal " LIMIT 1,7", @connection.add_limit_offset!("", :limit=>sql_inject)
175
+ assert_equal " LIMIT 1,7 OFFSET 7", @connection.add_limit_offset!("", :limit=>sql_inject, :offset=>7)
176
+ end
177
+ end
178
+ end
179
+
180
+ end