ibm_db 2.5.26-universal-darwin-14 → 2.6.1-universal-darwin-14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +11 -0
  3. data/MANIFEST +14 -14
  4. data/README +225 -225
  5. data/ext/Makefile.nt32 +181 -181
  6. data/ext/Makefile.nt32.191 +212 -212
  7. data/ext/extconf.rb +264 -261
  8. data/ext/extconf_MacOS.rb +269 -0
  9. data/ext/ibm_db.c +11879 -11793
  10. data/ext/ruby_ibm_db.h +241 -240
  11. data/ext/ruby_ibm_db_cli.c +851 -845
  12. data/ext/ruby_ibm_db_cli.h +500 -489
  13. data/init.rb +41 -41
  14. data/lib/IBM_DB.rb +27 -19
  15. data/lib/active_record/connection_adapters/ibm_db_adapter.rb +3339 -3289
  16. data/lib/active_record/connection_adapters/ibmdb_adapter.rb +1 -1
  17. data/lib/active_record/vendor/db2-i5-zOS.yaml +328 -328
  18. data/test/cases/adapter_test.rb +207 -207
  19. data/test/cases/associations/belongs_to_associations_test.rb +711 -711
  20. data/test/cases/associations/cascaded_eager_loading_test.rb +181 -181
  21. data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +851 -851
  22. data/test/cases/associations/join_model_test.rb +743 -743
  23. data/test/cases/attribute_methods_test.rb +822 -822
  24. data/test/cases/base_test.rb +2133 -2133
  25. data/test/cases/calculations_test.rb +482 -482
  26. data/test/cases/migration_test.rb +2408 -2408
  27. data/test/cases/persistence_test.rb +642 -642
  28. data/test/cases/query_cache_test.rb +257 -257
  29. data/test/cases/relations_test.rb +1182 -1182
  30. data/test/cases/schema_dumper_test.rb +256 -256
  31. data/test/cases/transaction_callbacks_test.rb +300 -300
  32. data/test/cases/validations/uniqueness_validation_test.rb +299 -299
  33. data/test/cases/xml_serialization_test.rb +408 -408
  34. data/test/config.yml +154 -154
  35. data/test/connections/native_ibm_db/connection.rb +43 -43
  36. data/test/ibm_db_test.rb +24 -24
  37. data/test/models/warehouse_thing.rb +4 -4
  38. data/test/schema/schema.rb +751 -751
  39. metadata +6 -8
  40. data/lib/linux/rb18x/ibm_db.bundle +0 -0
  41. data/lib/linux/rb19x/ibm_db.bundle +0 -0
  42. data/lib/linux/rb20x/ibm_db.bundle +0 -0
  43. data/lib/linux/rb21x/ibm_db.bundle +0 -0
@@ -1,257 +1,257 @@
1
- require "cases/helper"
2
- require 'models/topic'
3
- require 'models/task'
4
- require 'models/category'
5
- require 'models/post'
6
-
7
-
8
- class QueryCacheTest < ActiveRecord::TestCase
9
- fixtures :tasks, :topics, :categories, :posts, :categories_posts
10
-
11
- def setup
12
- Task.connection.clear_query_cache
13
- ActiveRecord::Base.connection.disable_query_cache!
14
- end
15
-
16
- def test_exceptional_middleware_clears_and_disables_cache_on_error
17
- assert !ActiveRecord::Base.connection.query_cache_enabled, 'cache off'
18
-
19
- mw = ActiveRecord::QueryCache.new lambda { |env|
20
- Task.find 1
21
- Task.find 1
22
- assert_equal 1, ActiveRecord::Base.connection.query_cache.length
23
- raise "lol borked"
24
- }
25
- assert_raises(RuntimeError) { mw.call({}) }
26
-
27
- assert_equal 0, ActiveRecord::Base.connection.query_cache.length
28
- assert !ActiveRecord::Base.connection.query_cache_enabled, 'cache off'
29
- end
30
-
31
- def test_exceptional_middleware_leaves_enabled_cache_alone
32
- ActiveRecord::Base.connection.enable_query_cache!
33
-
34
- mw = ActiveRecord::QueryCache.new lambda { |env|
35
- raise "lol borked"
36
- }
37
- assert_raises(RuntimeError) { mw.call({}) }
38
-
39
- assert ActiveRecord::Base.connection.query_cache_enabled, 'cache on'
40
- end
41
-
42
- def test_middleware_delegates
43
- called = false
44
- mw = ActiveRecord::QueryCache.new lambda { |env|
45
- called = true
46
- }
47
- mw.call({})
48
- assert called, 'middleware should delegate'
49
- end
50
-
51
- def test_middleware_caches
52
- mw = ActiveRecord::QueryCache.new lambda { |env|
53
- Task.find 1
54
- Task.find 1
55
- assert_equal 1, ActiveRecord::Base.connection.query_cache.length
56
- }
57
- mw.call({})
58
- end
59
-
60
- def test_cache_enabled_during_call
61
- assert !ActiveRecord::Base.connection.query_cache_enabled, 'cache off'
62
-
63
- mw = ActiveRecord::QueryCache.new lambda { |env|
64
- assert ActiveRecord::Base.connection.query_cache_enabled, 'cache on'
65
- }
66
- mw.call({})
67
- end
68
-
69
- def test_cache_on_during_body_write
70
- streaming = Class.new do
71
- def each
72
- yield ActiveRecord::Base.connection.query_cache_enabled
73
- end
74
- end
75
-
76
- mw = ActiveRecord::QueryCache.new lambda { |env|
77
- [200, {}, streaming.new]
78
- }
79
- body = mw.call({}).last
80
- body.each { |x| assert x, 'cache should be on' }
81
- body.close
82
- assert !ActiveRecord::Base.connection.query_cache_enabled, 'cache disabled'
83
- end
84
-
85
- def test_cache_off_after_close
86
- mw = ActiveRecord::QueryCache.new lambda { |env| }
87
- body = mw.call({}).last
88
-
89
- assert ActiveRecord::Base.connection.query_cache_enabled, 'cache enabled'
90
- body.close
91
- assert !ActiveRecord::Base.connection.query_cache_enabled, 'cache disabled'
92
- end
93
-
94
- def test_cache_clear_after_close
95
- mw = ActiveRecord::QueryCache.new lambda { |env|
96
- Post.find(:first)
97
- }
98
- body = mw.call({}).last
99
-
100
- assert !ActiveRecord::Base.connection.query_cache.empty?, 'cache not empty'
101
- body.close
102
- assert ActiveRecord::Base.connection.query_cache.empty?, 'cache should be empty'
103
- end
104
-
105
- def test_find_queries
106
- assert_queries(ActiveRecord::IdentityMap.enabled? ? 1 : 2) { Task.find(1); Task.find(1) }
107
- end
108
-
109
- def test_find_queries_with_cache
110
- Task.cache do
111
- assert_queries(1) { Task.find(1); Task.find(1) }
112
- end
113
- end
114
-
115
- def test_find_queries_with_cache_multi_record
116
- Task.cache do
117
- assert_queries(2) { Task.find(1); Task.find(1); Task.find(2) }
118
- end
119
- end
120
-
121
- def test_count_queries_with_cache
122
- Task.cache do
123
- assert_queries(1) { Task.count; Task.count }
124
- end
125
- end
126
-
127
- def test_query_cache_dups_results_correctly
128
- Task.cache do
129
- now = Time.now.utc
130
- task = Task.find 1
131
- assert_not_equal now, task.starting
132
- task.starting = now
133
- task.reload
134
- assert_not_equal now, task.starting
135
- end
136
- end
137
-
138
- def test_cache_is_flat
139
- Task.cache do
140
- Topic.columns # don't count this query
141
- assert_queries(1) { Topic.find(1); Topic.find(1); }
142
- end
143
-
144
- ActiveRecord::Base.cache do
145
- assert_queries(1) { Task.find(1); Task.find(1) }
146
- end
147
- end
148
-
149
- def test_cache_does_not_wrap_string_results_in_arrays
150
- if current_adapter?(:SQLite3Adapter)
151
- require 'sqlite3/version'
152
- sqlite3_version = RUBY_PLATFORM =~ /java/ ? Jdbc::SQLite3::VERSION : SQLite3::VERSION
153
- end
154
-
155
- Task.cache do
156
- # Oracle adapter returns count() as Fixnum or Float
157
- if current_adapter?(:OracleAdapter,:IBM_DBAdapter)
158
- assert_kind_of Numeric, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
159
- elsif current_adapter?(:SQLite3Adapter) && sqlite3_version > '1.2.5' || current_adapter?(:Mysql2Adapter) || current_adapter?(:MysqlAdapter)
160
- # Future versions of the sqlite3 adapter will return numeric
161
- assert_instance_of Fixnum,
162
- Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
163
- else
164
- assert_instance_of String, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
165
- end
166
- end
167
- end
168
- end
169
-
170
- class QueryCacheExpiryTest < ActiveRecord::TestCase
171
- fixtures :tasks, :posts, :categories, :categories_posts
172
-
173
- def test_cache_gets_cleared_after_migration
174
- # warm the cache
175
- Post.find(1)
176
-
177
- # change the column definition
178
- Post.connection.change_column :posts, :title, :string, :limit => 80
179
- assert_nothing_raised { Post.find(1) }
180
-
181
- # restore the old definition
182
- Post.connection.change_column :posts, :title, :string
183
- end
184
-
185
- def test_find
186
- Task.connection.expects(:clear_query_cache).times(1)
187
-
188
- assert !Task.connection.query_cache_enabled
189
- Task.cache do
190
- assert Task.connection.query_cache_enabled
191
- Task.find(1)
192
-
193
- Task.uncached do
194
- assert !Task.connection.query_cache_enabled
195
- Task.find(1)
196
- end
197
-
198
- assert Task.connection.query_cache_enabled
199
- end
200
- assert !Task.connection.query_cache_enabled
201
- end
202
-
203
- def test_update
204
- Task.connection.expects(:clear_query_cache).times(2)
205
-
206
- Task.cache do
207
- task = Task.find(1)
208
- task.starting = Time.now.utc
209
- task.save!
210
- end
211
- end
212
-
213
- def test_destroy
214
- Task.connection.expects(:clear_query_cache).times(2)
215
-
216
- Task.cache do
217
- Task.find(1).destroy
218
- end
219
- end
220
-
221
- def test_insert
222
- ActiveRecord::Base.connection.expects(:clear_query_cache).times(2)
223
-
224
- Task.cache do
225
- Task.create!
226
- end
227
- end
228
-
229
- def test_cache_is_expired_by_habtm_update
230
- ActiveRecord::Base.connection.expects(:clear_query_cache).times(2)
231
- ActiveRecord::Base.cache do
232
- c = Category.find(:first)
233
- p = Post.find(:first)
234
- p.categories << c
235
- end
236
- end
237
-
238
- def test_cache_is_expired_by_habtm_delete
239
- ActiveRecord::Base.connection.expects(:clear_query_cache).times(2)
240
- ActiveRecord::Base.cache do
241
- p = Post.find(1)
242
- assert p.categories.any?
243
- p.categories.delete_all
244
- end
245
- end
246
- end
247
-
248
- class QueryCacheBodyProxyTest < ActiveRecord::TestCase
249
-
250
- test "is polite to it's body and responds to it" do
251
- body = Class.new(String) { def to_path; "/path"; end }.new
252
- proxy = ActiveRecord::QueryCache::BodyProxy.new(nil, body, ActiveRecord::Base.connection_id)
253
- assert proxy.respond_to?(:to_path)
254
- assert_equal proxy.to_path, "/path"
255
- end
256
-
257
- end
1
+ require "cases/helper"
2
+ require 'models/topic'
3
+ require 'models/task'
4
+ require 'models/category'
5
+ require 'models/post'
6
+
7
+
8
+ class QueryCacheTest < ActiveRecord::TestCase
9
+ fixtures :tasks, :topics, :categories, :posts, :categories_posts
10
+
11
+ def setup
12
+ Task.connection.clear_query_cache
13
+ ActiveRecord::Base.connection.disable_query_cache!
14
+ end
15
+
16
+ def test_exceptional_middleware_clears_and_disables_cache_on_error
17
+ assert !ActiveRecord::Base.connection.query_cache_enabled, 'cache off'
18
+
19
+ mw = ActiveRecord::QueryCache.new lambda { |env|
20
+ Task.find 1
21
+ Task.find 1
22
+ assert_equal 1, ActiveRecord::Base.connection.query_cache.length
23
+ raise "lol borked"
24
+ }
25
+ assert_raises(RuntimeError) { mw.call({}) }
26
+
27
+ assert_equal 0, ActiveRecord::Base.connection.query_cache.length
28
+ assert !ActiveRecord::Base.connection.query_cache_enabled, 'cache off'
29
+ end
30
+
31
+ def test_exceptional_middleware_leaves_enabled_cache_alone
32
+ ActiveRecord::Base.connection.enable_query_cache!
33
+
34
+ mw = ActiveRecord::QueryCache.new lambda { |env|
35
+ raise "lol borked"
36
+ }
37
+ assert_raises(RuntimeError) { mw.call({}) }
38
+
39
+ assert ActiveRecord::Base.connection.query_cache_enabled, 'cache on'
40
+ end
41
+
42
+ def test_middleware_delegates
43
+ called = false
44
+ mw = ActiveRecord::QueryCache.new lambda { |env|
45
+ called = true
46
+ }
47
+ mw.call({})
48
+ assert called, 'middleware should delegate'
49
+ end
50
+
51
+ def test_middleware_caches
52
+ mw = ActiveRecord::QueryCache.new lambda { |env|
53
+ Task.find 1
54
+ Task.find 1
55
+ assert_equal 1, ActiveRecord::Base.connection.query_cache.length
56
+ }
57
+ mw.call({})
58
+ end
59
+
60
+ def test_cache_enabled_during_call
61
+ assert !ActiveRecord::Base.connection.query_cache_enabled, 'cache off'
62
+
63
+ mw = ActiveRecord::QueryCache.new lambda { |env|
64
+ assert ActiveRecord::Base.connection.query_cache_enabled, 'cache on'
65
+ }
66
+ mw.call({})
67
+ end
68
+
69
+ def test_cache_on_during_body_write
70
+ streaming = Class.new do
71
+ def each
72
+ yield ActiveRecord::Base.connection.query_cache_enabled
73
+ end
74
+ end
75
+
76
+ mw = ActiveRecord::QueryCache.new lambda { |env|
77
+ [200, {}, streaming.new]
78
+ }
79
+ body = mw.call({}).last
80
+ body.each { |x| assert x, 'cache should be on' }
81
+ body.close
82
+ assert !ActiveRecord::Base.connection.query_cache_enabled, 'cache disabled'
83
+ end
84
+
85
+ def test_cache_off_after_close
86
+ mw = ActiveRecord::QueryCache.new lambda { |env| }
87
+ body = mw.call({}).last
88
+
89
+ assert ActiveRecord::Base.connection.query_cache_enabled, 'cache enabled'
90
+ body.close
91
+ assert !ActiveRecord::Base.connection.query_cache_enabled, 'cache disabled'
92
+ end
93
+
94
+ def test_cache_clear_after_close
95
+ mw = ActiveRecord::QueryCache.new lambda { |env|
96
+ Post.find(:first)
97
+ }
98
+ body = mw.call({}).last
99
+
100
+ assert !ActiveRecord::Base.connection.query_cache.empty?, 'cache not empty'
101
+ body.close
102
+ assert ActiveRecord::Base.connection.query_cache.empty?, 'cache should be empty'
103
+ end
104
+
105
+ def test_find_queries
106
+ assert_queries(ActiveRecord::IdentityMap.enabled? ? 1 : 2) { Task.find(1); Task.find(1) }
107
+ end
108
+
109
+ def test_find_queries_with_cache
110
+ Task.cache do
111
+ assert_queries(1) { Task.find(1); Task.find(1) }
112
+ end
113
+ end
114
+
115
+ def test_find_queries_with_cache_multi_record
116
+ Task.cache do
117
+ assert_queries(2) { Task.find(1); Task.find(1); Task.find(2) }
118
+ end
119
+ end
120
+
121
+ def test_count_queries_with_cache
122
+ Task.cache do
123
+ assert_queries(1) { Task.count; Task.count }
124
+ end
125
+ end
126
+
127
+ def test_query_cache_dups_results_correctly
128
+ Task.cache do
129
+ now = Time.now.utc
130
+ task = Task.find 1
131
+ assert_not_equal now, task.starting
132
+ task.starting = now
133
+ task.reload
134
+ assert_not_equal now, task.starting
135
+ end
136
+ end
137
+
138
+ def test_cache_is_flat
139
+ Task.cache do
140
+ Topic.columns # don't count this query
141
+ assert_queries(1) { Topic.find(1); Topic.find(1); }
142
+ end
143
+
144
+ ActiveRecord::Base.cache do
145
+ assert_queries(1) { Task.find(1); Task.find(1) }
146
+ end
147
+ end
148
+
149
+ def test_cache_does_not_wrap_string_results_in_arrays
150
+ if current_adapter?(:SQLite3Adapter)
151
+ require 'sqlite3/version'
152
+ sqlite3_version = RUBY_PLATFORM =~ /java/ ? Jdbc::SQLite3::VERSION : SQLite3::VERSION
153
+ end
154
+
155
+ Task.cache do
156
+ # Oracle adapter returns count() as Fixnum or Float
157
+ if current_adapter?(:OracleAdapter,:IBM_DBAdapter)
158
+ assert_kind_of Numeric, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
159
+ elsif current_adapter?(:SQLite3Adapter) && sqlite3_version > '1.2.5' || current_adapter?(:Mysql2Adapter) || current_adapter?(:MysqlAdapter)
160
+ # Future versions of the sqlite3 adapter will return numeric
161
+ assert_instance_of Fixnum,
162
+ Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
163
+ else
164
+ assert_instance_of String, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
165
+ end
166
+ end
167
+ end
168
+ end
169
+
170
+ class QueryCacheExpiryTest < ActiveRecord::TestCase
171
+ fixtures :tasks, :posts, :categories, :categories_posts
172
+
173
+ def test_cache_gets_cleared_after_migration
174
+ # warm the cache
175
+ Post.find(1)
176
+
177
+ # change the column definition
178
+ Post.connection.change_column :posts, :title, :string, :limit => 80
179
+ assert_nothing_raised { Post.find(1) }
180
+
181
+ # restore the old definition
182
+ Post.connection.change_column :posts, :title, :string
183
+ end
184
+
185
+ def test_find
186
+ Task.connection.expects(:clear_query_cache).times(1)
187
+
188
+ assert !Task.connection.query_cache_enabled
189
+ Task.cache do
190
+ assert Task.connection.query_cache_enabled
191
+ Task.find(1)
192
+
193
+ Task.uncached do
194
+ assert !Task.connection.query_cache_enabled
195
+ Task.find(1)
196
+ end
197
+
198
+ assert Task.connection.query_cache_enabled
199
+ end
200
+ assert !Task.connection.query_cache_enabled
201
+ end
202
+
203
+ def test_update
204
+ Task.connection.expects(:clear_query_cache).times(2)
205
+
206
+ Task.cache do
207
+ task = Task.find(1)
208
+ task.starting = Time.now.utc
209
+ task.save!
210
+ end
211
+ end
212
+
213
+ def test_destroy
214
+ Task.connection.expects(:clear_query_cache).times(2)
215
+
216
+ Task.cache do
217
+ Task.find(1).destroy
218
+ end
219
+ end
220
+
221
+ def test_insert
222
+ ActiveRecord::Base.connection.expects(:clear_query_cache).times(2)
223
+
224
+ Task.cache do
225
+ Task.create!
226
+ end
227
+ end
228
+
229
+ def test_cache_is_expired_by_habtm_update
230
+ ActiveRecord::Base.connection.expects(:clear_query_cache).times(2)
231
+ ActiveRecord::Base.cache do
232
+ c = Category.find(:first)
233
+ p = Post.find(:first)
234
+ p.categories << c
235
+ end
236
+ end
237
+
238
+ def test_cache_is_expired_by_habtm_delete
239
+ ActiveRecord::Base.connection.expects(:clear_query_cache).times(2)
240
+ ActiveRecord::Base.cache do
241
+ p = Post.find(1)
242
+ assert p.categories.any?
243
+ p.categories.delete_all
244
+ end
245
+ end
246
+ end
247
+
248
+ class QueryCacheBodyProxyTest < ActiveRecord::TestCase
249
+
250
+ test "is polite to it's body and responds to it" do
251
+ body = Class.new(String) { def to_path; "/path"; end }.new
252
+ proxy = ActiveRecord::QueryCache::BodyProxy.new(nil, body, ActiveRecord::Base.connection_id)
253
+ assert proxy.respond_to?(:to_path)
254
+ assert_equal proxy.to_path, "/path"
255
+ end
256
+
257
+ end