sequel 0.5.0.2 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/COPYING +18 -18
  2. data/Rakefile +17 -98
  3. data/lib/sequel.rb +2 -71
  4. metadata +10 -108
  5. data/CHANGELOG +0 -989
  6. data/bin/sequel +0 -41
  7. data/lib/sequel/adapters/adapter_skeleton.rb +0 -68
  8. data/lib/sequel/adapters/ado.rb +0 -100
  9. data/lib/sequel/adapters/db2.rb +0 -158
  10. data/lib/sequel/adapters/dbi.rb +0 -126
  11. data/lib/sequel/adapters/informix.rb +0 -87
  12. data/lib/sequel/adapters/jdbc.rb +0 -108
  13. data/lib/sequel/adapters/mysql.rb +0 -269
  14. data/lib/sequel/adapters/odbc.rb +0 -145
  15. data/lib/sequel/adapters/odbc_mssql.rb +0 -93
  16. data/lib/sequel/adapters/openbase.rb +0 -90
  17. data/lib/sequel/adapters/oracle.rb +0 -99
  18. data/lib/sequel/adapters/postgres.rb +0 -519
  19. data/lib/sequel/adapters/sqlite.rb +0 -192
  20. data/lib/sequel/ado.rb +0 -6
  21. data/lib/sequel/array_keys.rb +0 -296
  22. data/lib/sequel/connection_pool.rb +0 -152
  23. data/lib/sequel/core_ext.rb +0 -59
  24. data/lib/sequel/core_sql.rb +0 -191
  25. data/lib/sequel/database.rb +0 -433
  26. data/lib/sequel/dataset.rb +0 -409
  27. data/lib/sequel/dataset/convenience.rb +0 -321
  28. data/lib/sequel/dataset/sequelizer.rb +0 -354
  29. data/lib/sequel/dataset/sql.rb +0 -586
  30. data/lib/sequel/db2.rb +0 -6
  31. data/lib/sequel/dbi.rb +0 -6
  32. data/lib/sequel/exceptions.rb +0 -45
  33. data/lib/sequel/informix.rb +0 -6
  34. data/lib/sequel/migration.rb +0 -191
  35. data/lib/sequel/model.rb +0 -8
  36. data/lib/sequel/mysql.rb +0 -6
  37. data/lib/sequel/odbc.rb +0 -6
  38. data/lib/sequel/oracle.rb +0 -6
  39. data/lib/sequel/postgres.rb +0 -6
  40. data/lib/sequel/pretty_table.rb +0 -73
  41. data/lib/sequel/schema.rb +0 -8
  42. data/lib/sequel/schema/schema_generator.rb +0 -131
  43. data/lib/sequel/schema/schema_sql.rb +0 -131
  44. data/lib/sequel/sqlite.rb +0 -6
  45. data/lib/sequel/worker.rb +0 -58
  46. data/spec/adapters/informix_spec.rb +0 -139
  47. data/spec/adapters/mysql_spec.rb +0 -330
  48. data/spec/adapters/oracle_spec.rb +0 -130
  49. data/spec/adapters/postgres_spec.rb +0 -189
  50. data/spec/adapters/sqlite_spec.rb +0 -345
  51. data/spec/array_keys_spec.rb +0 -679
  52. data/spec/connection_pool_spec.rb +0 -356
  53. data/spec/core_ext_spec.rb +0 -67
  54. data/spec/core_sql_spec.rb +0 -301
  55. data/spec/database_spec.rb +0 -811
  56. data/spec/dataset_spec.rb +0 -2381
  57. data/spec/migration_spec.rb +0 -261
  58. data/spec/pretty_table_spec.rb +0 -66
  59. data/spec/rcov.opts +0 -4
  60. data/spec/schema_generator_spec.rb +0 -86
  61. data/spec/schema_spec.rb +0 -230
  62. data/spec/sequel_spec.rb +0 -10
  63. data/spec/sequelizer_spec.rb +0 -389
  64. data/spec/spec.opts +0 -5
  65. data/spec/spec_helper.rb +0 -44
  66. data/spec/worker_spec.rb +0 -96
@@ -1,679 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'spec_helper')
2
-
3
- context "An array with symbol keys" do
4
- setup do
5
- @a = [1, 2, 3]
6
- @a.keys = [:a, :b, :c]
7
- end
8
-
9
- specify "should provide subscript access" do
10
- @a[0].should == 1
11
- @a[0..1].should == [1, 2]
12
-
13
- @a[1] = 4
14
- @a.should == [1, 4, 3]
15
- end
16
-
17
- specify "should provide key access using symbols" do
18
- @a[:a].should == 1
19
- @a[:b].should == 2
20
- @a[:B].should == nil
21
-
22
- @a[:a] = 11
23
- @a.should == [11, 2, 3]
24
- @a[:a].should == 11
25
-
26
- @a[:d] = 4
27
- @a.should == [11, 2, 3, 4]
28
- @a.keys.should == [:a, :b, :c, :d]
29
- end
30
-
31
- specify "should provide key access using strings" do
32
- @a['a'].should == 1
33
- @a['A'].should be_nil
34
-
35
- @a['d'] = 4
36
- @a.should == [1, 2, 3, 4]
37
- @a.keys.should == [:a, :b, :c, :d]
38
- end
39
-
40
- specify "should provide #store functionality" do
41
- @a.store(:a, 11)
42
- @a.should == [11, 2, 3]
43
-
44
- @a.store(:d, 4)
45
- @a.should == [11, 2, 3, 4]
46
-
47
- @a.store('d', 44)
48
- @a.should == [11, 2, 3, 44]
49
- end
50
-
51
- specify "should provide #to_hash/#to_h functionality" do
52
- @a.to_hash.should == {:a => 1, :b => 2, :c => 3}
53
- @a.to_h.should == {:a => 1, :b => 2, :c => 3}
54
- end
55
-
56
- specify "should provide #columns as alias to #keys" do
57
- @a.columns.should == [:a, :b, :c]
58
- @a.columns = [:x, :y, :z]
59
-
60
- @a[:x].should == 1
61
- end
62
-
63
- specify "should provide #slice functionality with keys" do
64
- s = @a.slice(0, 2)
65
- s.should == [1, 2]
66
- s.keys.should == [:a, :b]
67
-
68
- s = @a.slice(1..2)
69
- s.should == [2, 3]
70
- s.keys.should == [:b, :c]
71
- end
72
-
73
- specify "should provide #each_pair iterator" do
74
- pairs = []
75
- @a.each_pair {|k, v| pairs << [k, v]}
76
- pairs.should == [[:a, 1], [:b, 2], [:c, 3]]
77
- end
78
-
79
- specify "should provide stock #delete functionality for arrays without keys" do
80
- a = [1, 2, 3]
81
- a.delete(2)
82
- a.should == [1, 3]
83
- end
84
-
85
- specify "should provide key-based #delete functionality" do
86
- @a.delete(:b)
87
- @a.should == [1, 3]
88
- @a.keys.should == [:a, :c]
89
- @a[:a].should == 1
90
- @a[:c].should == 3
91
- end
92
-
93
- specify "should separate array keys after #delete/#delete_at" do
94
- b = @a.dup
95
-
96
- b.delete(:b)
97
-
98
- @a.keys.should == [:a, :b, :c]
99
- b.keys.should == [:a, :c]
100
- @a.should == [1, 2, 3]
101
- b.should == [1, 3]
102
- @a[:b].should == 2
103
- b[:b].should == nil
104
- end
105
-
106
- specify "should provide #each_key functionality" do
107
- keys = []
108
- @a.each_key {|k| keys << k}
109
- keys.should == [:a, :b, :c]
110
- end
111
-
112
- specify "should provide #each_value functionality" do
113
- values = []
114
- @a.each_value {|v| values << v}
115
- values.should == [1, 2, 3]
116
- end
117
-
118
- specify "should provide stock #include? functionality for arrays without keys" do
119
- [1, 2, 3].include?(2).should be_true
120
- [1, 2, 3].include?(4).should be_false
121
- end
122
-
123
- specify "should provide #has_key?/#member?/#key?/#include? functionality" do
124
- @a.has_key?(:a).should be_true
125
- @a.has_key?(:b).should be_true
126
- @a.has_key?(:c).should be_true
127
- @a.has_key?(:B).should be_false
128
- @a.has_key?(:d).should be_false
129
-
130
- @a.has_key?('a').should be_true
131
- @a.has_key?('b').should be_true
132
- @a.has_key?('c').should be_true
133
- @a.has_key?('A').should be_false
134
- @a.has_key?('d').should be_false
135
-
136
- @a.key?(:a).should be_true
137
- @a.key?(:b).should be_true
138
- @a.key?(:c).should be_true
139
- @a.key?(:B).should be_false
140
- @a.key?(:d).should be_false
141
-
142
- @a.key?('a').should be_true
143
- @a.key?('b').should be_true
144
- @a.key?('c').should be_true
145
- @a.key?('A').should be_false
146
- @a.key?('d').should be_false
147
-
148
- @a.member?(:a).should be_true
149
- @a.member?(:b).should be_true
150
- @a.member?(:c).should be_true
151
- @a.member?(:B).should be_false
152
- @a.member?(:d).should be_false
153
-
154
- @a.member?('a').should be_true
155
- @a.member?('b').should be_true
156
- @a.member?('c').should be_true
157
- @a.member?('A').should be_false
158
- @a.member?('d').should be_false
159
-
160
- @a.include?(:a).should be_true
161
- @a.include?(:b).should be_true
162
- @a.include?(:c).should be_true
163
- @a.include?(:B).should be_false
164
- @a.include?(:d).should be_false
165
-
166
- @a.include?('a').should be_true
167
- @a.include?('b').should be_true
168
- @a.include?('c').should be_true
169
- @a.include?('A').should be_false
170
- @a.include?('d').should be_false
171
- end
172
-
173
- specify "should provide original #include? functionality for arrays without keys" do
174
- [1, 2, 3].include?(:a).should be_false
175
- [1, 2, 3].include?(1).should be_true
176
- end
177
-
178
- specify "should provide #has_value?/#value? functionality" do
179
- @a.has_value?(1).should be_true
180
- @a.has_value?(2).should be_true
181
- @a.has_value?(3).should be_true
182
- @a.has_value?(4).should be_false
183
-
184
- @a.value?(1).should be_true
185
- @a.value?(2).should be_true
186
- @a.value?(3).should be_true
187
- @a.value?(4).should be_false
188
- end
189
-
190
- specify "should provide #fetch functionality" do
191
- @a.fetch(:a).should == 1
192
- @a.fetch(:b).should == 2
193
- @a.fetch(:c).should == 3
194
- proc {@a.fetch(:d)}.should raise_error(IndexError)
195
- @a.fetch(:d, 4).should == 4
196
- @a.fetch(:d, nil).should == nil
197
-
198
- @a.fetch(:a) {|v| v.to_s}.should == '1'
199
- @a.fetch(:d, 4) {|v| v.to_s}.should == '4'
200
- end
201
-
202
- specify "should provide #values functionality" do
203
- @a.values.should == [1, 2, 3]
204
- end
205
-
206
- specify "should provide #dup functionality" do
207
- b = @a.dup
208
- b.should == [1, 2, 3]
209
- b.keys.should == @a.keys
210
-
211
- b[:a].should == 1
212
- b[:b].should == 2
213
- b[:c].should == 3
214
- b[:d].should be_nil
215
-
216
- @a.keys << :e
217
- @a.keys.should == [:a, :b, :c, :e]
218
- b.keys.should == @a.keys
219
- end
220
-
221
- specify "should provide #clone functionality" do
222
- b = @a.clone
223
- b.should == [1, 2, 3]
224
- b.keys.should == @a.keys
225
-
226
- b[:a].should == 1
227
- b[:b].should == 2
228
- b[:c].should == 3
229
- b[:d].should be_nil
230
-
231
- @a.keys << :e
232
- @a.keys.should == [:a, :b, :c, :e]
233
- b.keys.should_not == @a.keys
234
- end
235
-
236
- specify "should provide #merge functionality" do
237
- @a.merge(@a).to_hash.should == {:a => 1, :b => 2, :c => 3}
238
-
239
- @a.merge({:b => 22, :d => 4}).to_hash.should == {:a => 1, :b => 22, :c => 3, :d => 4}
240
-
241
- b = [1, 2, 3]
242
- b.keys = [:b, :c, :d]
243
- @a.merge(b).to_hash.should == {:a => 1, :b => 1, :c => 2, :d => 3}
244
-
245
- # call with a block. The block returns the old value passed to it
246
- @a.merge(b) {|k, o, n| o}.to_hash.should == {:a => 1, :b => 2, :c => 3, :d => 3}
247
- end
248
-
249
- specify "should provide #merge!/#update!/#update functionality" do
250
- @a.merge!(@a)
251
- @a.to_hash.should == {:a => 1, :b => 2, :c => 3}
252
-
253
- @a.update(:b => 22)
254
- @a.to_hash.should == {:a => 1, :b => 22, :c => 3}
255
-
256
- b = [1, 2, 3]
257
- b.keys = [:b, :c, :d]
258
- @a.update!(b)
259
- @a.to_hash.should == {:a => 1, :b => 1, :c => 2, :d => 3}
260
- end
261
- end
262
-
263
- context "An array with string keys" do
264
- setup do
265
- @a = [1, 2, 3]
266
- @a.keys = ['a', 'b', 'c']
267
- end
268
-
269
- specify "should provide key access using symbols" do
270
- @a[:a].should == 1
271
- @a[:b].should == 2
272
- @a[:B].should == nil
273
-
274
- @a[:a] = 11
275
- @a.should == [11, 2, 3]
276
- @a[:a].should == 11
277
-
278
- @a[:d] = 4
279
- @a.should == [11, 2, 3, 4]
280
- @a.keys.should == ['a', 'b', 'c', :d]
281
- end
282
-
283
- specify "should provide key access using strings" do
284
- @a['a'].should == 1
285
- @a['A'].should be_nil
286
-
287
- @a['d'] = 4
288
- @a.should == [1, 2, 3, 4]
289
- @a.keys.should == ['a', 'b', 'c', :d]
290
- end
291
-
292
- specify "should provide #store functionality" do
293
- @a.store(:a, 11)
294
- @a.should == [11, 2, 3]
295
-
296
- @a.store(:d, 4)
297
- @a.should == [11, 2, 3, 4]
298
-
299
- @a.store('d', 44)
300
- @a.should == [11, 2, 3, 44]
301
- end
302
-
303
- specify "should provide #to_hash/#to_h functionality" do
304
- @a.to_hash.should == {:a => 1, :b => 2, :c => 3}
305
- @a.to_h.should == {:a => 1, :b => 2, :c => 3}
306
- end
307
-
308
- specify "should provide #columns as alias to #keys" do
309
- @a.columns.should == ['a', 'b', 'c']
310
- @a.columns = [:x, :y, :z]
311
-
312
- @a[:x].should == 1
313
- end
314
-
315
- specify "should provide #slice functionality with keys" do
316
- s = @a.slice(0, 2)
317
- s.should == [1, 2]
318
- s.keys.should == ['a', 'b']
319
-
320
- s = @a.slice(1..2)
321
- s.should == [2, 3]
322
- s.keys.should == ['b', 'c']
323
- end
324
-
325
- specify "should provide #each_pair iterator" do
326
- pairs = []
327
- @a.each_pair {|k, v| pairs << [k, v]}
328
- pairs.should == [['a', 1], ['b', 2], ['c', 3]]
329
- end
330
-
331
- specify "should provide key-based #delete functionality" do
332
- @a.delete(:b)
333
- @a.should == [1, 3]
334
- @a.keys.should == ['a', 'c']
335
- @a[:a].should == 1
336
- @a[:c].should == 3
337
- end
338
-
339
- specify "should provide #each_key functionality" do
340
- keys = []
341
- @a.each_key {|k| keys << k}
342
- keys.should == ['a', 'b', 'c']
343
- end
344
-
345
- specify "should provide #each_value functionality" do
346
- values = []
347
- @a.each_value {|v| values << v}
348
- values.should == [1, 2, 3]
349
- end
350
-
351
- specify "should provide #has_key?/#member?/#key?/#include? functionality" do
352
- @a.has_key?(:a).should be_true
353
- @a.has_key?(:b).should be_true
354
- @a.has_key?(:c).should be_true
355
- @a.has_key?(:B).should be_false
356
- @a.has_key?(:d).should be_false
357
-
358
- @a.has_key?('a').should be_true
359
- @a.has_key?('b').should be_true
360
- @a.has_key?('c').should be_true
361
- @a.has_key?('A').should be_false
362
- @a.has_key?('d').should be_false
363
-
364
- @a.key?(:a).should be_true
365
- @a.key?(:b).should be_true
366
- @a.key?(:c).should be_true
367
- @a.key?(:B).should be_false
368
- @a.key?(:d).should be_false
369
-
370
- @a.key?('a').should be_true
371
- @a.key?('b').should be_true
372
- @a.key?('c').should be_true
373
- @a.key?('A').should be_false
374
- @a.key?('d').should be_false
375
-
376
- @a.member?(:a).should be_true
377
- @a.member?(:b).should be_true
378
- @a.member?(:c).should be_true
379
- @a.member?(:B).should be_false
380
- @a.member?(:d).should be_false
381
-
382
- @a.member?('a').should be_true
383
- @a.member?('b').should be_true
384
- @a.member?('c').should be_true
385
- @a.member?('A').should be_false
386
- @a.member?('d').should be_false
387
-
388
- @a.include?(:a).should be_true
389
- @a.include?(:b).should be_true
390
- @a.include?(:c).should be_true
391
- @a.include?(:B).should be_false
392
- @a.include?(:d).should be_false
393
-
394
- @a.include?('a').should be_true
395
- @a.include?('b').should be_true
396
- @a.include?('c').should be_true
397
- @a.include?('A').should be_false
398
- @a.include?('d').should be_false
399
- end
400
-
401
- specify "should provide original #include? functionality for arrays without keys" do
402
- [1, 2, 3].include?(:a).should be_false
403
- [1, 2, 3].include?(1).should be_true
404
- end
405
-
406
- specify "should provide #has_value?/#value? functionality" do
407
- @a.has_value?(1).should be_true
408
- @a.has_value?(2).should be_true
409
- @a.has_value?(3).should be_true
410
- @a.has_value?(4).should be_false
411
-
412
- @a.value?(1).should be_true
413
- @a.value?(2).should be_true
414
- @a.value?(3).should be_true
415
- @a.value?(4).should be_false
416
- end
417
-
418
- specify "should provide #fetch functionality" do
419
- @a.fetch(:a).should == 1
420
- @a.fetch(:b).should == 2
421
- @a.fetch(:c).should == 3
422
- proc {@a.fetch(:d)}.should raise_error(IndexError)
423
- @a.fetch(:d, 4).should == 4
424
- @a.fetch(:d, nil).should == nil
425
-
426
- @a.fetch(:a) {|v| v.to_s}.should == '1'
427
- @a.fetch(:d, 4) {|v| v.to_s}.should == '4'
428
- end
429
-
430
- specify "should provide #values functionality" do
431
- @a.values.should == [1, 2, 3]
432
- end
433
-
434
- specify "should provide #dup functionality" do
435
- b = @a.dup
436
- b.should == [1, 2, 3]
437
- b.keys.should == @a.keys
438
-
439
- b[:a].should == 1
440
- b[:b].should == 2
441
- b[:c].should == 3
442
- b[:d].should be_nil
443
-
444
- @a.keys << :e
445
- @a.keys.should == ['a', 'b', 'c', :e]
446
- b.keys.should == @a.keys
447
- end
448
-
449
- specify "should provide #clone functionality" do
450
- b = @a.clone
451
- b.should == [1, 2, 3]
452
- b.keys.should == @a.keys
453
-
454
- b[:a].should == 1
455
- b[:b].should == 2
456
- b[:c].should == 3
457
- b[:d].should be_nil
458
-
459
- @a.keys << :e
460
- @a.keys.should == ['a', 'b', 'c', :e]
461
- b.keys.should_not == @a.keys
462
- end
463
-
464
- specify "should provide #merge functionality" do
465
- @a.merge(@a).to_hash.should == {:a => 1, :b => 2, :c => 3}
466
-
467
- @a.merge({:b => 22, :d => 4}).to_hash.should == {:a => 1, :b => 22, :c => 3, :d => 4}
468
-
469
- b = [1, 2, 3]
470
- b.keys = [:b, :c, :d]
471
- @a.merge(b).to_hash.should == {:a => 1, :b => 1, :c => 2, :d => 3}
472
-
473
- # call with a block. The block returns the old value passed to it
474
- @a.merge(b) {|k, o, n| o}.to_hash.should == {:a => 1, :b => 2, :c => 3, :d => 3}
475
- end
476
-
477
- specify "should provide #merge!/#update!/#update functionality" do
478
- @a.merge!(@a)
479
- @a.to_hash.should == {:a => 1, :b => 2, :c => 3}
480
-
481
- @a.update(:b => 22)
482
- @a.to_hash.should == {:a => 1, :b => 22, :c => 3}
483
-
484
- b = [1, 2, 3]
485
- b.keys = [:b, :c, :d]
486
- @a.update!(b)
487
- @a.to_hash.should == {:a => 1, :b => 1, :c => 2, :d => 3}
488
- end
489
- end
490
-
491
- context "Array.from_hash" do
492
- specify "should construct an array with keys from a hash" do
493
- h = {:x => 1, :y => 2, :z => 3}
494
- a = Array.from_hash(h)
495
- a.to_hash.should == h
496
- end
497
- end
498
-
499
- context "Sequel.use_array_tuples" do
500
- setup do
501
- @c = Class.new(Sequel::Dataset) do
502
- def fetch_rows(sql, &block)
503
- block[{:a => 1, :b => 2, :c => 3}]
504
- end
505
- end
506
-
507
- @ds = @c.new(nil).from(:items)
508
- end
509
-
510
- teardown do
511
- Sequel.use_hash_tuples
512
- end
513
-
514
- specify "should cause the dataset to return array tuples instead of hashes" do
515
- @ds.first.should == {:a => 1, :b => 2, :c => 3}
516
- Sequel.use_array_tuples
517
- a = @ds.first
518
- a.class.should == Array
519
- a.values.sort.should == [1, 2, 3]
520
- a.keys.map {|k| k.to_s}.sort.should == ['a', 'b', 'c']
521
- a[:a].should == 1
522
- a[:b].should == 2
523
- a[:c].should == 3
524
- a[:d].should == nil
525
-
526
- @ds.transform(:a => [proc {|v| v.to_s}, proc {|v| v.to_i}])
527
- a = @ds.first
528
- a[:a].should == '1'
529
-
530
- @ds.transform({})
531
- a = @ds.first
532
- a[:a].should == 1
533
-
534
- @ds.set_model(Hash)
535
- end
536
-
537
- specify "should work correctly with dataset with transforms" do
538
- @ds.first.should == {:a => 1, :b => 2, :c => 3}
539
- Sequel.use_array_tuples
540
-
541
- @ds.transform(:a => [proc {|x| x + 10}, proc {|x| x - 10}])
542
- a = @ds.first
543
- a.class.should == Array
544
- a[:a].should == 11
545
- a[:b].should == 2
546
- a[:c].should == 3
547
- a[:d].should == nil
548
-
549
- a = @ds.all[0]
550
- a.class.should == Array
551
- a[:a].should == 11
552
- a[:b].should == 2
553
- a[:c].should == 3
554
- a[:d].should == nil
555
- end
556
-
557
- specify "should work correctly with dataset with model" do
558
- ccc = Class.new do
559
- attr_reader :values
560
- def initialize(v)
561
- @values = v
562
- end
563
- end
564
-
565
- @ds.first.should == {:a => 1, :b => 2, :c => 3}
566
- Sequel.use_array_tuples
567
-
568
- @ds.set_model(ccc)
569
- a = @ds.first
570
- a.class.should == ccc
571
- a.values.class.should == Array
572
- a.values[:a].should == 1
573
- a.values[:b].should == 2
574
- a.values[:c].should == 3
575
- a.values[:d].should == nil
576
-
577
- a = @ds.all[0]
578
- a.class.should == ccc
579
- a.values.class.should == Array
580
- a.values[:a].should == 1
581
- a.values[:b].should == 2
582
- a.values[:c].should == 3
583
- a.values[:d].should == nil
584
-
585
- @ds.each(:naked => true) do |a|
586
- a.class.should == Array
587
- a[:a].should == 1
588
- a[:b].should == 2
589
- a[:c].should == 3
590
- a[:d].should == nil
591
- end
592
- end
593
-
594
- specify "should work correctly with dataset with model and transform" do
595
- ccc = Class.new do
596
- attr_reader :values
597
- def initialize(v)
598
- @values = v
599
- end
600
- end
601
-
602
- @ds.first.should == {:a => 1, :b => 2, :c => 3}
603
- Sequel.use_array_tuples
604
-
605
- @ds.transform(:a => [proc {|x| x + 10}, proc {|x| x - 10}])
606
- @ds.set_model(ccc)
607
- a = @ds.first
608
- a.class.should == ccc
609
- a.values.class.should == Array
610
- a.values[:a].should == 11
611
- a.values[:b].should == 2
612
- a.values[:c].should == 3
613
- a.values[:d].should == nil
614
-
615
- a = @ds.all[0]
616
- a.class.should == ccc
617
- a.values.class.should == Array
618
- a.values[:a].should == 11
619
- a.values[:b].should == 2
620
- a.values[:c].should == 3
621
- a.values[:d].should == nil
622
-
623
- @ds.each(:naked => true) do |a|
624
- a.class.should == Array
625
- a[:a].should == 11
626
- a[:b].should == 2
627
- a[:c].should == 3
628
- a[:d].should == nil
629
- end
630
- end
631
-
632
- specify "should work correctly with denuded dataset" do
633
- ccc = Class.new do
634
- attr_reader :values
635
- def initialize(v)
636
- @values = v
637
- end
638
- end
639
-
640
- @ds.first.should == {:a => 1, :b => 2, :c => 3}
641
- Sequel.use_array_tuples
642
-
643
- @ds.set_model(ccc)
644
- @ds.set_model(nil)
645
-
646
- a = @ds.first
647
- a.class.should == Array
648
- a[:a].should == 1
649
- a[:b].should == 2
650
- a[:c].should == 3
651
- a[:d].should == nil
652
-
653
- a = @ds.all[0]
654
- a.class.should == Array
655
- a[:a].should == 1
656
- a[:b].should == 2
657
- a[:c].should == 3
658
- a[:d].should == nil
659
- end
660
-
661
- specify "should be reversible using Sequel.use_hash_tuples" do
662
- Sequel.use_array_tuples
663
- @ds.first.class.should == Array
664
-
665
- Sequel.use_hash_tuples
666
- @ds.first.should == {:a => 1, :b => 2, :c => 3}
667
- end
668
-
669
- specify "should apply and unapply correctly to dataset with array_tuples_fetch_rows" do
670
- @c.class_def(:fetch_rows) {'yo hash'}
671
- @c.class_def(:array_tuples_fetch_rows) {'yo array'}
672
- Sequel.use_array_tuples
673
-
674
- @ds.fetch_rows.should == 'yo array'
675
-
676
- Sequel.use_hash_tuples
677
- @ds.fetch_rows.should == 'yo hash'
678
- end
679
- end