ibm_db 2.5.6-x86-mswin32-60 → 2.5.7-x86-mswin32-60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. data/CHANGES +6 -0
  2. data/README +1 -1
  3. data/ext/Makefile.nt32 +3 -3
  4. data/ext/Makefile.nt32.191 +212 -0
  5. data/ext/ibm_db.c +30 -5
  6. data/lib/active_record/connection_adapters/ibm_db_adapter.rb +300 -108
  7. data/lib/active_record/connection_adapters/ibm_db_pstmt.rb +1 -1
  8. data/lib/mswin32/rb18x/ibm_db.so +0 -0
  9. data/test/cases/adapter_test.rb +25 -22
  10. data/test/cases/associations/belongs_to_associations_test.rb +245 -43
  11. data/test/cases/associations/cascaded_eager_loading_test.rb +28 -26
  12. data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +60 -156
  13. data/test/cases/associations/join_model_test.rb +96 -146
  14. data/test/cases/attribute_methods_test.rb +98 -33
  15. data/test/cases/base_test.rb +525 -103
  16. data/test/cases/calculations_test.rb +92 -8
  17. data/test/cases/migration_test.rb +533 -207
  18. data/test/cases/persistence_test.rb +636 -0
  19. data/test/cases/query_cache_test.rb +242 -0
  20. data/test/cases/relations_test.rb +1019 -0
  21. data/test/cases/schema_dumper_test.rb +37 -17
  22. data/test/cases/transaction_callbacks_test.rb +300 -0
  23. data/test/cases/validations/uniqueness_validation_test.rb +38 -22
  24. data/test/cases/xml_serialization_test.rb +276 -0
  25. data/test/config.yml +154 -0
  26. data/test/connections/native_ibm_db/connection.rb +2 -0
  27. data/test/models/warehouse_thing.rb +4 -4
  28. data/test/schema/i5/ibm_db_specific_schema.rb +3 -1
  29. data/test/schema/ids/ibm_db_specific_schema.rb +3 -1
  30. data/test/schema/luw/ibm_db_specific_schema.rb +2 -0
  31. data/test/schema/schema.rb +174 -89
  32. data/test/schema/zOS/ibm_db_specific_schema.rb +3 -1
  33. metadata +9 -7
  34. data/lib/mswin32/rb19x/ibm_db.so +0 -0
  35. data/test/cases/associations/eager_test.rb +0 -862
  36. data/test/cases/associations/has_many_through_associations_test.rb +0 -461
  37. data/test/cases/finder_test.rb +0 -1088
  38. data/test/cases/fixtures_test.rb +0 -684
@@ -0,0 +1,276 @@
1
+ require "cases/helper"
2
+ require 'models/contact'
3
+ require 'models/post'
4
+ require 'models/author'
5
+ require 'models/comment'
6
+ require 'models/company_in_module'
7
+ require 'models/toy'
8
+
9
+ class XmlSerializationTest < ActiveRecord::TestCase
10
+ def test_should_serialize_default_root
11
+ @xml = Contact.new.to_xml
12
+ assert_match %r{^<contact>}, @xml
13
+ assert_match %r{</contact>$}, @xml
14
+ end
15
+
16
+ def test_should_serialize_default_root_with_namespace
17
+ @xml = Contact.new.to_xml :namespace=>"http://xml.rubyonrails.org/contact"
18
+ assert_match %r{^<contact xmlns="http://xml.rubyonrails.org/contact">}, @xml
19
+ assert_match %r{</contact>$}, @xml
20
+ end
21
+
22
+ def test_should_serialize_custom_root
23
+ @xml = Contact.new.to_xml :root => 'xml_contact'
24
+ assert_match %r{^<xml-contact>}, @xml
25
+ assert_match %r{</xml-contact>$}, @xml
26
+ end
27
+
28
+ def test_should_allow_undasherized_tags
29
+ @xml = Contact.new.to_xml :root => 'xml_contact', :dasherize => false
30
+ assert_match %r{^<xml_contact>}, @xml
31
+ assert_match %r{</xml_contact>$}, @xml
32
+ assert_match %r{<created_at}, @xml
33
+ end
34
+
35
+ def test_should_allow_camelized_tags
36
+ @xml = Contact.new.to_xml :root => 'xml_contact', :camelize => true
37
+ assert_match %r{^<XmlContact>}, @xml
38
+ assert_match %r{</XmlContact>$}, @xml
39
+ assert_match %r{<CreatedAt}, @xml
40
+ end
41
+
42
+ def test_should_allow_skipped_types
43
+ @xml = Contact.new(:age => 25).to_xml :skip_types => true
44
+ assert %r{<age>25</age>}.match(@xml)
45
+ end
46
+
47
+ def test_should_include_yielded_additions
48
+ @xml = Contact.new.to_xml do |xml|
49
+ xml.creator "David"
50
+ end
51
+ assert_match %r{<creator>David</creator>}, @xml
52
+ end
53
+ end
54
+
55
+ class DefaultXmlSerializationTest < ActiveRecord::TestCase
56
+ def setup
57
+ @xml = Contact.new(:name => 'aaron stack', :age => 25, :avatar => 'binarydata', :created_at => Time.utc(2006, 8, 1), :awesome => false, :preferences => { :gem => 'ruby' }).to_xml
58
+ end
59
+
60
+ def test_should_serialize_string
61
+ assert_match %r{<name>aaron stack</name>}, @xml
62
+ end
63
+
64
+ def test_should_serialize_integer
65
+ assert_match %r{<age type="integer">25</age>}, @xml
66
+ end
67
+
68
+ def test_should_serialize_binary
69
+ assert_match %r{YmluYXJ5ZGF0YQ==\n</avatar>}, @xml
70
+ assert_match %r{<avatar(.*)(type="binary")}, @xml
71
+ assert_match %r{<avatar(.*)(encoding="base64")}, @xml
72
+ end
73
+
74
+ def test_should_serialize_datetime
75
+ assert_match %r{<created-at type=\"datetime\">2006-08-01T00:00:00Z</created-at>}, @xml
76
+ end
77
+
78
+ def test_should_serialize_boolean
79
+ assert_match %r{<awesome type=\"boolean\">false</awesome>}, @xml
80
+ end
81
+
82
+ def test_should_serialize_hash
83
+ assert_match %r{<preferences>\s*<gem>ruby</gem>\s*</preferences>}m, @xml
84
+ end
85
+ end
86
+
87
+ class DefaultXmlSerializationTimezoneTest < ActiveRecord::TestCase
88
+ def test_should_serialize_datetime_with_timezone
89
+ timezone, Time.zone = Time.zone, "Pacific Time (US & Canada)"
90
+
91
+ toy = Toy.create(:name => 'Mickey', :updated_at => Time.utc(2006, 8, 1))
92
+ unless current_adapter?(:IBM_DBAdapter)
93
+ assert_match %r{<updated-at type=\"datetime\">2006-07-31T17:00:00-07:00</updated-at>}, toy.to_xml
94
+ else
95
+ assert_match %r{<updated-at type=\"timestamp\">2006-07-31 17:00:00 -0700</updated-at>}, toy.to_xml
96
+ end
97
+ ensure
98
+ Time.zone = timezone
99
+ end
100
+
101
+ def test_should_serialize_datetime_with_timezone_reloaded
102
+ timezone, Time.zone = Time.zone, "Pacific Time (US & Canada)"
103
+
104
+ toy = Toy.create(:name => 'Minnie', :updated_at => Time.utc(2006, 8, 1)).reload
105
+ unless current_adapter?(:IBM_DBAdapter)
106
+ assert_match %r{<updated-at type=\"datetime\">2006-07-31T17:00:00-07:00</updated-at>}, toy.to_xml
107
+ else
108
+ assert_match %r{<updated-at type=\"timestamp\">2006-07-31 17:00:00 -0700</updated-at>}, toy.to_xml
109
+ end
110
+ ensure
111
+ Time.zone = timezone
112
+ end
113
+ end
114
+
115
+ class NilXmlSerializationTest < ActiveRecord::TestCase
116
+ def setup
117
+ @xml = Contact.new.to_xml(:root => 'xml_contact')
118
+ end
119
+
120
+ def test_should_serialize_string
121
+ assert_match %r{<name nil="true"></name>}, @xml
122
+ end
123
+
124
+ def test_should_serialize_integer
125
+ assert %r{<age (.*)></age>}.match(@xml)
126
+ attributes = $1
127
+ assert_match %r{nil="true"}, attributes
128
+ assert_match %r{type="integer"}, attributes
129
+ end
130
+
131
+ def test_should_serialize_binary
132
+ assert %r{<avatar (.*)></avatar>}.match(@xml)
133
+ attributes = $1
134
+ assert_match %r{type="binary"}, attributes
135
+ assert_match %r{encoding="base64"}, attributes
136
+ assert_match %r{nil="true"}, attributes
137
+ end
138
+
139
+ def test_should_serialize_datetime
140
+ assert %r{<created-at (.*)></created-at>}.match(@xml)
141
+ attributes = $1
142
+ assert_match %r{nil="true"}, attributes
143
+ assert_match %r{type="datetime"}, attributes
144
+ end
145
+
146
+ def test_should_serialize_boolean
147
+ assert %r{<awesome (.*)></awesome>}.match(@xml)
148
+ attributes = $1
149
+ assert_match %r{type="boolean"}, attributes
150
+ assert_match %r{nil="true"}, attributes
151
+ end
152
+
153
+ def test_should_serialize_yaml
154
+ assert_match %r{<preferences nil=\"true\"></preferences>}, @xml
155
+ end
156
+ end
157
+
158
+ class DatabaseConnectedXmlSerializationTest < ActiveRecord::TestCase
159
+ fixtures :authors, :posts, :projects
160
+
161
+ # to_xml used to mess with the hash the user provided which
162
+ # caused the builder to be reused. This meant the document kept
163
+ # getting appended to.
164
+
165
+ def test_modules
166
+ projects = MyApplication::Business::Project.all
167
+ xml = projects.to_xml
168
+ root = projects.first.class.to_s.underscore.pluralize.tr('/','_').dasherize
169
+ assert_match "<#{root} type=\"array\">", xml
170
+ assert_match "</#{root}>", xml
171
+ end
172
+
173
+ def test_passing_hash_shouldnt_reuse_builder
174
+ options = {:include=>:posts}
175
+ david = authors(:david)
176
+ first_xml_size = david.to_xml(options).size
177
+ second_xml_size = david.to_xml(options).size
178
+ assert_equal first_xml_size, second_xml_size
179
+ end
180
+
181
+ def test_include_uses_association_name
182
+ xml = authors(:david).to_xml :include=>:hello_posts, :indent => 0
183
+ assert_match %r{<hello-posts type="array">}, xml
184
+ assert_match %r{<hello-post type="Post">}, xml
185
+ assert_match %r{<hello-post type="StiPost">}, xml
186
+ end
187
+
188
+ def test_included_associations_should_skip_types
189
+ xml = authors(:david).to_xml :include=>:hello_posts, :indent => 0, :skip_types => true
190
+ assert_match %r{<hello-posts>}, xml
191
+ assert_match %r{<hello-post>}, xml
192
+ assert_match %r{<hello-post>}, xml
193
+ end
194
+
195
+ def test_methods_are_called_on_object
196
+ xml = authors(:david).to_xml :methods => :label, :indent => 0
197
+ assert_match %r{<label>.*</label>}, xml
198
+ end
199
+
200
+ def test_should_not_call_methods_on_associations_that_dont_respond
201
+ xml = authors(:david).to_xml :include=>:hello_posts, :methods => :label, :indent => 2
202
+ assert !authors(:david).hello_posts.first.respond_to?(:label)
203
+ assert_match %r{^ <label>.*</label>}, xml
204
+ assert_no_match %r{^ <label>}, xml
205
+ end
206
+
207
+ def test_procs_are_called_on_object
208
+ proc = Proc.new { |options| options[:builder].tag!('nationality', 'Danish') }
209
+ xml = authors(:david).to_xml(:procs => [ proc ])
210
+ assert_match %r{<nationality>Danish</nationality>}, xml
211
+ end
212
+
213
+ def test_dual_arity_procs_are_called_on_object
214
+ proc = Proc.new { |options, record| options[:builder].tag!('name-reverse', record.name.reverse) }
215
+ xml = authors(:david).to_xml(:procs => [ proc ])
216
+ assert_match %r{<name-reverse>divaD</name-reverse>}, xml
217
+ end
218
+
219
+ def test_top_level_procs_arent_applied_to_associations
220
+ author_proc = Proc.new { |options| options[:builder].tag!('nationality', 'Danish') }
221
+ xml = authors(:david).to_xml(:procs => [ author_proc ], :include => :posts, :indent => 2)
222
+
223
+ assert_match %r{^ <nationality>Danish</nationality>}, xml
224
+ assert_no_match %r{^ {6}<nationality>Danish</nationality>}, xml
225
+ end
226
+
227
+ def test_procs_on_included_associations_are_called
228
+ posts_proc = Proc.new { |options| options[:builder].tag!('copyright', 'DHH') }
229
+ xml = authors(:david).to_xml(
230
+ :indent => 2,
231
+ :include => {
232
+ :posts => { :procs => [ posts_proc ] }
233
+ }
234
+ )
235
+
236
+ assert_no_match %r{^ <copyright>DHH</copyright>}, xml
237
+ assert_match %r{^ {6}<copyright>DHH</copyright>}, xml
238
+ end
239
+
240
+ def test_should_include_empty_has_many_as_empty_array
241
+ authors(:david).posts.delete_all
242
+ xml = authors(:david).to_xml :include=>:posts, :indent => 2
243
+
244
+ assert_equal [], Hash.from_xml(xml)['author']['posts']
245
+ assert_match %r{^ <posts type="array"/>}, xml
246
+ end
247
+
248
+ def test_should_has_many_array_elements_should_include_type_when_different_from_guessed_value
249
+ xml = authors(:david).to_xml :include=>:posts_with_comments, :indent => 2
250
+
251
+ assert Hash.from_xml(xml)
252
+ assert_match %r{^ <posts-with-comments type="array">}, xml
253
+ assert_match %r{^ <posts-with-comment type="Post">}, xml
254
+ assert_match %r{^ <posts-with-comment type="StiPost">}, xml
255
+
256
+ types = Hash.from_xml(xml)['author']['posts_with_comments'].collect {|t| t['type'] }
257
+ assert types.include?('SpecialPost')
258
+ assert types.include?('Post')
259
+ assert types.include?('StiPost')
260
+ end
261
+
262
+ def test_should_produce_xml_for_methods_returning_array
263
+ xml = authors(:david).to_xml(:methods => :social)
264
+ array = Hash.from_xml(xml)['author']['social']
265
+ assert_equal 2, array.size
266
+ assert array.include? 'twitter'
267
+ assert array.include? 'github'
268
+ end
269
+
270
+ def test_should_support_aliased_attributes
271
+ xml = Author.select("name as firstname").to_xml
272
+ array = Hash.from_xml(xml)['authors']
273
+ assert_equal array.size, array.select { |author| author.has_key? 'firstname' }.size
274
+ end
275
+
276
+ end
data/test/config.yml ADDED
@@ -0,0 +1,154 @@
1
+ default_connection: <%= defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3' %>
2
+
3
+ connections:
4
+ jdbcderby:
5
+ arunit: activerecord_unittest
6
+ arunit2: activerecord_unittest2
7
+
8
+ jdbch2:
9
+ arunit: activerecord_unittest
10
+ arunit2: activerecord_unittest2
11
+
12
+ jdbchsqldb:
13
+ arunit: activerecord_unittest
14
+ arunit2: activerecord_unittest2
15
+
16
+ jdbcmysql:
17
+ arunit:
18
+ username: rails
19
+ encoding: utf8
20
+ arunit2:
21
+ username: rails
22
+ encoding: utf8
23
+
24
+ jdbcpostgresql:
25
+ arunit:
26
+ username: <%= ENV['user'] || 'rails' %>
27
+ arunit2:
28
+ username: <%= ENV['user'] || 'rails' %>
29
+
30
+ jdbcsqlite3:
31
+ arunit:
32
+ database: <%= FIXTURES_ROOT %>/fixture_database.sqlite3
33
+ timeout: 5000
34
+ arunit2:
35
+ database: <%= FIXTURES_ROOT %>/fixture_database_2.sqlite3
36
+ timeout: 5000
37
+
38
+ db2:
39
+ arunit:
40
+ host: localhost
41
+ username: arunit
42
+ password: arunit
43
+ database: arunit
44
+ arunit2:
45
+ host: localhost
46
+ username: arunit
47
+ password: arunit
48
+ database: arunit2
49
+
50
+ ibm_db:
51
+ arunit:
52
+ username: db2user
53
+ password: secret
54
+ database: railsdb
55
+ start_id: 1000
56
+ arunit2:
57
+ username: db2user
58
+ password: secret
59
+ database: railsdb
60
+ start_id: 1000
61
+
62
+ firebird:
63
+ arunit:
64
+ host: localhost
65
+ username: rails
66
+ password: rails
67
+ charset: UTF8
68
+ arunit2:
69
+ host: localhost
70
+ username: rails
71
+ password: rails
72
+ charset: UTF8
73
+
74
+ frontbase:
75
+ arunit:
76
+ host: localhost
77
+ username: rails
78
+ session_name: unittest-<%= $$ %>
79
+ arunit2:
80
+ host: localhost
81
+ username: rails
82
+ session_name: unittest-<%= $$ %>
83
+
84
+ mysql:
85
+ arunit:
86
+ username: root
87
+ password: root123
88
+ port: 3306
89
+ database: railsdb
90
+ encoding: utf8
91
+ arunit2:
92
+ username: root
93
+ password: root123
94
+ port: 3306
95
+ database: railsdb
96
+ encoding: utf8
97
+
98
+ mysql2:
99
+ arunit:
100
+ username: rails
101
+ encoding: utf8
102
+ arunit2:
103
+ username: rails
104
+ encoding: utf8
105
+
106
+ openbase:
107
+ arunit:
108
+ username: admin
109
+ arunit2:
110
+ username: admin
111
+
112
+ oracle:
113
+ arunit:
114
+ adapter: oracle_enhanced
115
+ database: <%= ENV['ARUNIT_DB_NAME'] || 'orcl' %>
116
+ username: <%= ENV['ARUNIT_USER_NAME'] || 'arunit' %>
117
+ password: <%= ENV['ARUNIT_PASSWORD'] || 'arunit' %>
118
+ emulate_oracle_adapter: true
119
+ arunit2:
120
+ adapter: oracle_enhanced
121
+ database: <%= ENV['ARUNIT_DB_NAME'] || 'orcl' %>
122
+ username: <%= ENV['ARUNIT2_USER_NAME'] || 'arunit2' %>
123
+ password: <%= ENV['ARUNIT2_PASSWORD'] || 'arunit2' %>
124
+ emulate_oracle_adapter: true
125
+
126
+ postgresql:
127
+ arunit:
128
+ min_messages: warning
129
+ arunit2:
130
+ min_messages: warning
131
+
132
+ sqlite3:
133
+ arunit:
134
+ database: <%= FIXTURES_ROOT %>/fixture_database.sqlite3
135
+ timeout: 5000
136
+ arunit2:
137
+ database: <%= FIXTURES_ROOT %>/fixture_database_2.sqlite3
138
+ timeout: 5000
139
+
140
+ sqlite3_mem:
141
+ arunit:
142
+ adapter: sqlite3
143
+ database: ':memory:'
144
+ arunit2:
145
+ adapter: sqlite3
146
+ database: ':memory:'
147
+
148
+ sybase:
149
+ arunit:
150
+ host: database_ASE
151
+ username: sa
152
+ arunit2:
153
+ host: database_ASE
154
+ username: sa
@@ -1,3 +1,4 @@
1
+ =begin
1
2
  print "Using native IBM_DB\n"
2
3
  require_dependency 'models/course'
3
4
  require 'logger'
@@ -40,3 +41,4 @@ ActiveRecord::Base.configurations = {
40
41
 
41
42
  ActiveRecord::Base.establish_connection 'arunit'
42
43
  Course.establish_connection 'arunit2'
44
+ =end
@@ -1,5 +1,5 @@
1
- class WarehouseThing < ActiveRecord::Base
2
- set_table_name "warehouse_things"
3
-
4
- validates_uniqueness_of :value
1
+ class WarehouseThing < ActiveRecord::Base
2
+ set_table_name "warehouse_things"
3
+
4
+ validates_uniqueness_of :value
5
5
  end