db2 2.5.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGES +181 -0
  3. data/LICENSE +18 -0
  4. data/MANIFEST +14 -0
  5. data/ParameterizedQueries README +39 -0
  6. data/README +282 -0
  7. data/ext/Makefile.nt32 +181 -0
  8. data/ext/extconf.rb +66 -0
  9. data/ext/ibm_db.c +11166 -0
  10. data/ext/ruby_ibm_db.h +236 -0
  11. data/ext/ruby_ibm_db_cli.c +738 -0
  12. data/ext/ruby_ibm_db_cli.h +431 -0
  13. data/init.rb +42 -0
  14. data/lib/IBM_DB.rb +2 -0
  15. data/lib/active_record/connection_adapters/ibm_db_adapter.rb +2558 -0
  16. data/lib/active_record/connection_adapters/ibm_db_pstmt.rb +1965 -0
  17. data/lib/active_record/vendor/db2-i5-zOS.yaml +328 -0
  18. data/test/cases/adapter_test.rb +202 -0
  19. data/test/cases/associations/belongs_to_associations_test.rb +486 -0
  20. data/test/cases/associations/cascaded_eager_loading_test.rb +183 -0
  21. data/test/cases/associations/eager_test.rb +862 -0
  22. data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +917 -0
  23. data/test/cases/associations/has_many_through_associations_test.rb +461 -0
  24. data/test/cases/associations/join_model_test.rb +793 -0
  25. data/test/cases/attribute_methods_test.rb +621 -0
  26. data/test/cases/base_test.rb +1486 -0
  27. data/test/cases/calculations_test.rb +362 -0
  28. data/test/cases/finder_test.rb +1088 -0
  29. data/test/cases/fixtures_test.rb +684 -0
  30. data/test/cases/migration_test.rb +2014 -0
  31. data/test/cases/schema_dumper_test.rb +232 -0
  32. data/test/cases/validations/uniqueness_validation_test.rb +283 -0
  33. data/test/connections/native_ibm_db/connection.rb +42 -0
  34. data/test/ibm_db_test.rb +25 -0
  35. data/test/models/warehouse_thing.rb +5 -0
  36. data/test/schema/i5/ibm_db_specific_schema.rb +135 -0
  37. data/test/schema/ids/ibm_db_specific_schema.rb +138 -0
  38. data/test/schema/luw/ibm_db_specific_schema.rb +135 -0
  39. data/test/schema/schema.rb +647 -0
  40. data/test/schema/zOS/ibm_db_specific_schema.rb +206 -0
  41. metadata +105 -0
@@ -0,0 +1,647 @@
1
+ ActiveRecord::Schema.define do
2
+ def except(adapter_names_to_exclude)
3
+ unless [adapter_names_to_exclude].flatten.include?(adapter_name)
4
+ yield
5
+ end
6
+ end
7
+
8
+ #put adapter specific setup here
9
+ case adapter_name
10
+ # For Firebird, set the sequence values 10000 when create_table is called;
11
+ # this prevents primary key collisions between "normally" created records
12
+ # and fixture-based (YAML) records.
13
+ when "Firebird"
14
+ def create_table(*args, &block)
15
+ ActiveRecord::Base.connection.create_table(*args, &block)
16
+ ActiveRecord::Base.connection.execute "SET GENERATOR #{args.first}_seq TO 10000"
17
+ end
18
+ end
19
+
20
+
21
+ # Please keep these create table statements in alphabetical order
22
+ # unless the ordering matters. In which case, define them below
23
+ create_table :accounts, :force => true do |t|
24
+ t.integer :firm_id
25
+ t.string :firm_name
26
+ t.integer :credit_limit
27
+ end
28
+
29
+ create_table :admin_accounts, :force => true do |t|
30
+ t.string :name
31
+ end
32
+
33
+ create_table :admin_users, :force => true do |t|
34
+ t.string :name
35
+ t.references :account
36
+ end
37
+
38
+ create_table :audit_logs, :force => true do |t|
39
+ t.column :message, :string, :null=>false
40
+ t.column :developer_id, :integer, :null=>false
41
+ end
42
+
43
+ create_table :authors, :force => true do |t|
44
+ t.string :name, :null => false
45
+ t.integer :author_address_id
46
+ t.integer :author_address_extra_id
47
+ end
48
+
49
+ create_table :author_addresses, :force => true do |t|
50
+ end
51
+
52
+ create_table :author_favorites, :force => true do |t|
53
+ t.column :author_id, :integer
54
+ t.column :favorite_author_id, :integer
55
+ end
56
+
57
+
58
+ create_table :auto_id_tests, :force => true, :id => false do |t|
59
+ t.primary_key :auto_id
60
+ t.integer :value
61
+ end
62
+
63
+ create_table :binaries, :force => true do |t|
64
+ t.binary :data
65
+ end
66
+
67
+ create_table :birds, :force => true do |t|
68
+ t.string :name
69
+ t.string :color
70
+ t.integer :pirate_id
71
+ end
72
+
73
+ create_table :books, :force => true do |t|
74
+ t.column :name, :string
75
+ end
76
+
77
+ create_table :booleans, :force => true do |t|
78
+ t.boolean :value
79
+ end
80
+
81
+ create_table :camelcase, :force => true do |t|
82
+ t.string :name
83
+ end
84
+
85
+ create_table :cars, :force => true do |t|
86
+ t.string :name
87
+ t.integer :engines_count
88
+ t.integer :wheels_count
89
+ end
90
+
91
+ create_table :categories, :force => true do |t|
92
+ t.string :name, :null => false
93
+ t.string :type
94
+ t.integer :categorizations_count
95
+ end
96
+
97
+ create_table :categories_posts, :force => true, :id => false do |t|
98
+ t.integer :category_id, :null => false
99
+ t.integer :post_id, :null => false
100
+ end
101
+
102
+ create_table :categorizations, :force => true do |t|
103
+ t.column :category_id, :integer
104
+ t.column :post_id, :integer
105
+ t.column :author_id, :integer
106
+ end
107
+
108
+ create_table :citations, :force => true do |t|
109
+ t.column :book1_id, :integer
110
+ t.column :book2_id, :integer
111
+ end
112
+
113
+ create_table :clubs, :force => true do |t|
114
+ t.string :name
115
+ end
116
+
117
+ create_table :collections, :force => true do |t|
118
+ t.string :name
119
+ end
120
+
121
+ create_table :colnametests, :force => true do |t|
122
+ t.integer :references, :null => false
123
+ end
124
+
125
+ except 'IBM_DB' do
126
+ create_table :comments, :force => true do |t|
127
+ t.integer :post_id, :null => false
128
+ t.text :body, :null => false
129
+ t.string :type
130
+ end
131
+ end
132
+
133
+ create_table :companies, :force => true do |t|
134
+ t.string :type
135
+ t.string :ruby_type
136
+ t.integer :firm_id
137
+ t.string :firm_name
138
+ t.string :name
139
+ t.integer :client_of
140
+ t.integer :rating, :default => 1
141
+ end
142
+
143
+ add_index :companies, [:firm_id, :type, :rating, :ruby_type], :name => "company_index"
144
+
145
+ create_table :computers, :force => true do |t|
146
+ t.integer :developer, :null => false
147
+ t.integer :extendedWarranty, :null => false
148
+ end
149
+
150
+ create_table :contracts, :force => true do |t|
151
+ t.integer :developer_id
152
+ t.integer :company_id
153
+ end
154
+
155
+ create_table :customers, :force => true do |t|
156
+ t.string :name
157
+ t.integer :balance, :default => 0
158
+ t.string :address_street
159
+ t.string :address_city
160
+ t.string :address_country
161
+ t.string :gps_location
162
+ end
163
+
164
+ create_table :dashboards, :force => true, :id => false do |t|
165
+ t.string :dashboard_id
166
+ t.string :name
167
+ end
168
+
169
+ create_table :developers, :force => true do |t|
170
+ t.string :name
171
+ t.integer :salary, :default => 70000
172
+ t.datetime :created_at
173
+ t.datetime :updated_at
174
+ end
175
+
176
+ create_table :developers_projects, :force => true, :id => false do |t|
177
+ t.integer :developer_id, :null => false
178
+ t.integer :project_id, :null => false
179
+ t.date :joined_on
180
+ t.integer :access_level, :default => 1
181
+ end
182
+
183
+ create_table :edges, :force => true, :id => false do |t|
184
+ t.column :source_id, :integer, :null => false
185
+ t.column :sink_id, :integer, :null => false
186
+ end
187
+ add_index :edges, [:source_id, :sink_id], :unique => true, :name => 'unique_edge_index'
188
+
189
+ create_table :engines, :force => true do |t|
190
+ t.integer :car_id
191
+ end
192
+
193
+ create_table :tyres, :force => true do |t|
194
+ t.integer :car_id
195
+ end
196
+
197
+ create_table :bulbs, :force => true do |t|
198
+ t.integer :car_id
199
+ t.string :name
200
+ end
201
+
202
+ create_table :entrants, :force => true do |t|
203
+ t.string :name, :null => false
204
+ t.integer :course_id, :null => false
205
+ end
206
+
207
+ create_table :essays, :force => true do |t|
208
+ t.string :name
209
+ t.string :writer_id
210
+ t.string :writer_type
211
+ end
212
+
213
+ create_table :events, :force => true do |t|
214
+ t.string :title, :limit => 5
215
+ end
216
+
217
+ create_table :funny_jokes, :force => true do |t|
218
+ t.string :name
219
+ end
220
+
221
+ create_table :goofy_string_id, :force => true, :id => false do |t|
222
+ t.string :id, :null => false
223
+ t.string :info
224
+ end
225
+
226
+ create_table :invoices, :force => true do |t|
227
+ t.integer :balance
228
+ t.datetime :updated_at
229
+ end
230
+
231
+ except 'IBM_DB' do
232
+ create_table :items, :force => true do |t|
233
+ t.column :name, :string
234
+ end
235
+ end
236
+
237
+ create_table :inept_wizards, :force => true do |t|
238
+ t.column :name, :string, :null => false
239
+ t.column :city, :string, :null => false
240
+ t.column :type, :string
241
+ end
242
+
243
+
244
+ create_table :jobs, :force => true do |t|
245
+ t.integer :ideal_reference_id
246
+ end
247
+
248
+ create_table :keyboards, :force => true, :id => false do |t|
249
+ t.primary_key :key_number
250
+ t.string :name
251
+ end
252
+
253
+ create_table :legacy_things, :force => true do |t|
254
+ t.integer :tps_report_number
255
+ t.integer :version, :null => false, :default => 0
256
+ end
257
+
258
+ create_table :line_items, :force => true do |t|
259
+ t.integer :invoice_id
260
+ t.integer :amount
261
+ end
262
+
263
+ create_table :lock_without_defaults, :force => true do |t|
264
+ t.column :lock_version, :integer
265
+ end
266
+
267
+ create_table :lock_without_defaults_cust, :force => true do |t|
268
+ t.column :custom_lock_version, :integer
269
+ end
270
+
271
+ create_table :mateys, :id => false, :force => true do |t|
272
+ t.column :pirate_id, :integer
273
+ t.column :target_id, :integer
274
+ t.column :weight, :integer
275
+ end
276
+
277
+ create_table :members, :force => true do |t|
278
+ t.string :name
279
+ t.integer :member_type_id
280
+ end
281
+
282
+ create_table :member_details, :force => true do |t|
283
+ t.integer :member_id
284
+ t.integer :organization_id
285
+ t.string :extra_data
286
+ end
287
+
288
+ create_table :memberships, :force => true do |t|
289
+ t.datetime :joined_on
290
+ t.integer :club_id, :member_id
291
+ t.boolean :favourite, :default => false
292
+ t.string :type
293
+ end
294
+
295
+ create_table :member_types, :force => true do |t|
296
+ t.string :name
297
+ end
298
+
299
+ create_table :references, :force => true do |t|
300
+ t.integer :person_id
301
+ t.integer :job_id
302
+ t.boolean :favourite
303
+ t.integer :lock_version, :default => 0
304
+ end
305
+
306
+ create_table :minivans, :force => true, :id => false do |t|
307
+ t.string :minivan_id
308
+ t.string :name
309
+ t.string :speedometer_id
310
+ t.string :color
311
+ end
312
+
313
+ create_table :minimalistics, :force => true do |t|
314
+ end
315
+
316
+ create_table :mixed_case_monkeys, :force => true, :id => false do |t|
317
+ t.primary_key :monkeyID
318
+ t.integer :fleaCount
319
+ end
320
+
321
+ create_table :mixins, :force => true do |t|
322
+ t.integer :parent_id
323
+ t.integer :pos
324
+ t.datetime :created_at
325
+ t.datetime :updated_at
326
+ t.integer :lft
327
+ t.integer :rgt
328
+ t.integer :root_id
329
+ t.string :type
330
+ end
331
+
332
+ create_table :movies, :force => true, :id => false do |t|
333
+ t.primary_key :movieid
334
+ t.string :name
335
+ end
336
+
337
+ create_table :numeric_data, :force => true do |t|
338
+ t.decimal :bank_balance, :precision => 10, :scale => 2
339
+ t.decimal :big_bank_balance, :precision => 15, :scale => 2
340
+ t.decimal :world_population, :precision => 10, :scale => 0
341
+ t.decimal :my_house_population, :precision => 2, :scale => 0
342
+ t.decimal :decimal_number_with_default, :precision => 3, :scale => 2, :default => 2.78
343
+ t.float :temperature
344
+ # Oracle supports precision up to 38
345
+ if current_adapter?(:OracleAdapter)
346
+ t.decimal :atoms_in_universe, :precision => 38, :scale => 0
347
+ elsif current_adapter?(:IBM_DBAdapter)
348
+ t.decimal :atoms_in_universe, :precision => 31, :scale => 0
349
+ else
350
+ t.decimal :atoms_in_universe, :precision => 55, :scale => 0
351
+ end
352
+ end
353
+
354
+ create_table :orders, :force => true do |t|
355
+ t.string :name
356
+ t.integer :billing_customer_id
357
+ t.integer :shipping_customer_id
358
+ end
359
+
360
+ create_table :organizations, :force => true do |t|
361
+ t.string :name
362
+ end
363
+
364
+ create_table :owners, :primary_key => :owner_id ,:force => true do |t|
365
+ t.string :name
366
+ t.column :updated_at, :datetime
367
+ t.column :happy_at, :datetime
368
+ end
369
+
370
+ except 'IBM_DB' do
371
+ create_table :paint_colors, :force => true do |t|
372
+ t.integer :non_poly_one_id
373
+ end
374
+
375
+ create_table :paint_textures, :force => true do |t|
376
+ t.integer :non_poly_two_id
377
+ end
378
+ end
379
+
380
+ create_table :parrots, :force => true do |t|
381
+ t.column :name, :string
382
+ t.column :parrot_sti_class, :string
383
+ t.column :killer_id, :integer
384
+ t.column :created_at, :datetime
385
+ t.column :created_on, :datetime
386
+ t.column :updated_at, :datetime
387
+ t.column :updated_on, :datetime
388
+ end
389
+
390
+ create_table :parrots_pirates, :id => false, :force => true do |t|
391
+ t.column :parrot_id, :integer
392
+ t.column :pirate_id, :integer
393
+ end
394
+
395
+ create_table :parrots_treasures, :id => false, :force => true do |t|
396
+ t.column :parrot_id, :integer
397
+ t.column :treasure_id, :integer
398
+ end
399
+
400
+ create_table :people, :force => true do |t|
401
+ t.string :first_name, :null => false
402
+ t.references :primary_contact
403
+ t.string :gender, :limit => 1
404
+ t.references :number1_fan
405
+ t.integer :lock_version, :null => false, :default => 0
406
+ end
407
+
408
+ create_table :pets, :primary_key => :pet_id ,:force => true do |t|
409
+ t.string :name
410
+ t.integer :owner_id, :integer
411
+ end
412
+
413
+ create_table :pirates, :force => true do |t|
414
+ t.column :catchphrase, :string
415
+ t.column :parrot_id, :integer
416
+ t.column :created_on, :datetime
417
+ t.column :updated_on, :datetime
418
+ end
419
+
420
+ except 'IBM_DB' do
421
+ create_table :posts, :force => true do |t|
422
+ t.integer :author_id
423
+ t.string :title, :null => false
424
+ t.text :body, :null => false
425
+ t.string :type
426
+ t.integer :comments_count, :default => 0
427
+ t.integer :taggings_count, :default => 0
428
+ end
429
+ end
430
+
431
+ create_table :price_estimates, :force => true do |t|
432
+ t.string :estimate_of_type
433
+ t.integer :estimate_of_id
434
+ t.integer :price
435
+ end
436
+
437
+ create_table :products, :force => true do |t|
438
+ t.references :collection
439
+ t.string :name
440
+ end
441
+
442
+ create_table :projects, :force => true do |t|
443
+ t.string :name
444
+ t.string :type
445
+ end
446
+
447
+ create_table :readers, :force => true do |t|
448
+ t.integer :post_id, :null => false
449
+ t.integer :person_id, :null => false
450
+ t.boolean :skimmer, :default => false
451
+ end
452
+
453
+ create_table :shape_expressions, :force => true do |t|
454
+ t.string :paint_type
455
+ t.integer :paint_id
456
+ t.string :shape_type
457
+ t.integer :shape_id
458
+ end
459
+
460
+ create_table :ships, :force => true do |t|
461
+ t.string :name
462
+ t.integer :pirate_id
463
+ t.datetime :created_at
464
+ t.datetime :created_on
465
+ t.datetime :updated_at
466
+ t.datetime :updated_on
467
+ end
468
+
469
+ create_table :ship_parts, :force => true do |t|
470
+ t.string :name
471
+ t.integer :ship_id
472
+ end
473
+
474
+ create_table :speedometers, :force => true, :id => false do |t|
475
+ t.string :speedometer_id
476
+ t.string :name
477
+ t.string :dashboard_id
478
+ end
479
+
480
+ create_table :sponsors, :force => true do |t|
481
+ t.integer :club_id
482
+ t.integer :sponsorable_id
483
+ t.string :sponsorable_type
484
+ end
485
+
486
+ create_table :subscribers, :force => true, :id => false do |t|
487
+ t.string :nick, :null => false
488
+ t.string :name
489
+ end
490
+ add_index :subscribers, :nick, :unique => true
491
+
492
+ create_table :subscriptions, :force => true do |t|
493
+ t.string :subscriber_id
494
+ t.integer :book_id
495
+ end
496
+
497
+ create_table :tasks, :force => true do |t|
498
+ t.datetime :starting
499
+ t.datetime :ending
500
+ end
501
+
502
+ except 'IBM_DB' do
503
+ create_table :topics, :force => true do |t|
504
+ t.string :title
505
+ t.string :author_name
506
+ t.string :author_email_address
507
+ t.datetime :written_on
508
+ t.time :bonus_time
509
+ t.date :last_read
510
+ t.text :content
511
+ t.boolean :approved, :default => true
512
+ t.integer :replies_count, :default => 0
513
+ t.integer :parent_id
514
+ t.string :parent_title
515
+ t.string :type
516
+ end
517
+ end
518
+
519
+ create_table :taggings, :force => true do |t|
520
+ t.column :tag_id, :integer
521
+ t.column :super_tag_id, :integer
522
+ t.column :taggable_type, :string
523
+ t.column :taggable_id, :integer
524
+ end
525
+
526
+ create_table :tags, :force => true do |t|
527
+ t.column :name, :string
528
+ t.column :taggings_count, :integer, :default => 0
529
+ end
530
+
531
+ create_table :toys, :primary_key => :toy_id ,:force => true do |t|
532
+ t.string :name
533
+ t.integer :pet_id, :integer
534
+ end
535
+
536
+ create_table :traffic_lights, :force => true do |t|
537
+ t.string :location
538
+ t.string :state
539
+ t.datetime :created_at
540
+ t.datetime :updated_at
541
+ end
542
+
543
+ create_table :treasures, :force => true do |t|
544
+ t.column :name, :string
545
+ t.column :looter_id, :integer
546
+ t.column :looter_type, :string
547
+ end
548
+
549
+ create_table :variants, :force => true do |t|
550
+ t.references :product
551
+ t.string :name
552
+ end
553
+
554
+ create_table :vertices, :force => true do |t|
555
+ t.column :label, :string
556
+ end
557
+
558
+ create_table 'warehouse_things', :force => true do |t|
559
+ t.integer :value
560
+ end
561
+
562
+ [:circles, :squares, :triangles, :non_poly_ones, :non_poly_twos].each do |t|
563
+ create_table(t, :force => true) { }
564
+ end
565
+
566
+ create_table :guids, :force => true do |t|
567
+ t.column :key, :string
568
+ end
569
+
570
+ create_table :integer_limits, :force => true do |t|
571
+ t.integer :"c_int_without_limit"
572
+ (1..8).each do |i|
573
+ t.integer :"c_int_#{i}", :limit => i
574
+ end
575
+ end
576
+
577
+ # NOTE - the following 4 tables are used by models that have :inverse_of options on the associations
578
+ create_table :men, :force => true do |t|
579
+ t.string :name
580
+ end
581
+
582
+ create_table :faces, :force => true do |t|
583
+ t.string :description
584
+ t.integer :man_id
585
+ t.integer :polymorphic_man_id
586
+ t.string :polymorphic_man_type
587
+ end
588
+
589
+ create_table :interests, :force => true do |t|
590
+ t.string :topic
591
+ t.integer :man_id
592
+ t.integer :polymorphic_man_id
593
+ t.string :polymorphic_man_type
594
+ t.integer :zine_id
595
+ end
596
+
597
+ create_table :wheels, :force => true do |t|
598
+ t.references :wheelable, :polymorphic => true
599
+ end
600
+
601
+ create_table :zines, :force => true do |t|
602
+ t.string :title
603
+ end
604
+
605
+ create_table :countries, :force => true, :id => false, :primary_key => 'country_id' do |t|
606
+ t.string :country_id
607
+ t.string :name
608
+ end
609
+ create_table :treaties, :force => true, :id => false, :primary_key => 'treaty_id' do |t|
610
+ t.string :treaty_id
611
+ t.string :name
612
+ end
613
+ create_table :countries_treaties, :force => true, :id => false do |t|
614
+ t.string :country_id, :null => false
615
+ t.string :treaty_id, :null => false
616
+ t.datetime :created_at
617
+ t.datetime :updated_at
618
+ end
619
+
620
+ create_table :liquid, :force => true do |t|
621
+ t.string :name
622
+ end
623
+ create_table :molecules, :force => true do |t|
624
+ t.integer :liquid_id
625
+ t.string :name
626
+ end
627
+ create_table :electrons, :force => true do |t|
628
+ t.integer :molecule_id
629
+ t.string :name
630
+ end
631
+
632
+ except ['SQLite','IBM_DB'] do
633
+ # fk_test_has_fk should be before fk_test_has_pk
634
+ create_table :fk_test_has_fk, :force => true do |t|
635
+ t.integer :fk_id, :null => false
636
+ end
637
+
638
+ create_table :fk_test_has_pk, :force => true do |t|
639
+ end
640
+
641
+ execute "ALTER TABLE fk_test_has_fk ADD CONSTRAINT fk_name FOREIGN KEY (#{quote_column_name 'fk_id'}) REFERENCES #{quote_table_name 'fk_test_has_pk'} (#{quote_column_name 'id'})"
642
+ end
643
+ end
644
+
645
+ Course.connection.create_table :courses, :force => true do |t|
646
+ t.column :name, :string, :null => false
647
+ end