KirbyBase 2.6 → 2.6.1
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.
- data/README +65 -67
- data/bin/kbserver.rb +18 -18
- data/changes.txt +144 -137
- data/examples/aaa_try_this_first/kbtest.rb +237 -237
- data/examples/add_column_test/add_column_test.rb +27 -27
- data/examples/calculated_field_test/calculated_field_test.rb +51 -51
- data/examples/change_column_type_test/change_column_type_test.rb +25 -25
- data/examples/column_required_test/column_required_test.rb +44 -44
- data/examples/crosstab_test/crosstab_test.rb +100 -100
- data/examples/csv_import_test/csv_import_test.rb +31 -31
- data/examples/csv_import_test/plane.csv +11 -11
- data/examples/default_value_test/default_value_test.rb +54 -54
- data/examples/drop_column_test/drop_column_test.rb +24 -24
- data/examples/indexes_test/add_index_test.rb +46 -46
- data/examples/indexes_test/drop_index_test.rb +65 -65
- data/examples/indexes_test/index_test.rb +94 -94
- data/examples/kbserver_as_win32_service/kbserver_daemon.rb +47 -47
- data/examples/kbserver_as_win32_service/kbserverctl.rb +75 -75
- data/examples/link_many_test/link_many_test.rb +70 -70
- data/examples/lookup_field_test/lookup_field_test.rb +55 -55
- data/examples/lookup_field_test/lookup_field_test_2.rb +62 -62
- data/examples/lookup_field_test/the_hal_fulton_feature_test.rb +69 -69
- data/examples/many_to_many_test/many_to_many_test.rb +65 -65
- data/examples/memo_test/memo_test.rb +74 -74
- data/examples/record_class_test/record_class_test.rb +77 -77
- data/examples/record_class_test/record_class_test2.rb +31 -31
- data/examples/rename_column_test/rename_column_test.rb +45 -45
- data/examples/rename_table_test/rename_table_test.rb +38 -38
- data/examples/yaml_field_test/yaml_field_test.rb +47 -47
- data/kirbybaserubymanual.html +2324 -2324
- data/lib/kirbybase.rb +3907 -3880
- data/test/tc_local_table.rb +108 -108
- metadata +56 -54
data/test/tc_local_table.rb
CHANGED
@@ -82,7 +82,7 @@ class TestTableLocal < Test::Unit::TestCase
|
|
82
82
|
tbl = @db.create_table(:plane, :name, :String, :speed, :Integer
|
83
83
|
) { |t| t.encrypt = @encrypted }
|
84
84
|
|
85
|
-
assert_equal(1, tbl.insert('Spitfire', 500))
|
85
|
+
assert_equal(1, tbl.insert('Spitfire', 500))
|
86
86
|
end
|
87
87
|
|
88
88
|
def test_insert_002
|
@@ -90,7 +90,7 @@ class TestTableLocal < Test::Unit::TestCase
|
|
90
90
|
) { |t| t.encrypt = @encrypted }
|
91
91
|
tbl.insert('Spitfire', 500)
|
92
92
|
|
93
|
-
assert_equal([1, 'Spitfire', 500], tbl[1].to_a)
|
93
|
+
assert_equal([1, 'Spitfire', 500], tbl[1].to_a)
|
94
94
|
end
|
95
95
|
|
96
96
|
def test_insert_003
|
@@ -98,7 +98,7 @@ class TestTableLocal < Test::Unit::TestCase
|
|
98
98
|
) { |t| t.encrypt = @encrypted }
|
99
99
|
tbl.insert(:name => 'Spitfire', :speed => 500)
|
100
100
|
|
101
|
-
assert_equal([1, 'Spitfire', 500], tbl[1].to_a)
|
101
|
+
assert_equal([1, 'Spitfire', 500], tbl[1].to_a)
|
102
102
|
end
|
103
103
|
|
104
104
|
def test_insert_004
|
@@ -106,7 +106,7 @@ class TestTableLocal < Test::Unit::TestCase
|
|
106
106
|
) { |t| t.encrypt = @encrypted }
|
107
107
|
tbl.insert { |r| r.name = 'Spitfire'; r.speed = 500 }
|
108
108
|
|
109
|
-
assert_equal([1, 'Spitfire', 500], tbl[1].to_a)
|
109
|
+
assert_equal([1, 'Spitfire', 500], tbl[1].to_a)
|
110
110
|
end
|
111
111
|
|
112
112
|
def test_insert_005
|
@@ -114,7 +114,7 @@ class TestTableLocal < Test::Unit::TestCase
|
|
114
114
|
) { |t| t.encrypt = @encrypted }
|
115
115
|
tbl.insert('Spitfire', nil)
|
116
116
|
|
117
|
-
assert_equal([1, 'Spitfire', nil], tbl[1].to_a)
|
117
|
+
assert_equal([1, 'Spitfire', nil], tbl[1].to_a)
|
118
118
|
end
|
119
119
|
|
120
120
|
def test_insert_006
|
@@ -123,7 +123,7 @@ class TestTableLocal < Test::Unit::TestCase
|
|
123
123
|
t.encrypt = @encrypted }
|
124
124
|
tbl.insert('Spitfire', nil)
|
125
125
|
|
126
|
-
assert_equal([1, 'Spitfire', nil], tbl[1].to_a)
|
126
|
+
assert_equal([1, 'Spitfire', nil], tbl[1].to_a)
|
127
127
|
end
|
128
128
|
|
129
129
|
def test_insert_007
|
@@ -132,7 +132,7 @@ class TestTableLocal < Test::Unit::TestCase
|
|
132
132
|
) { |t| t.encrypt = @encrypted }
|
133
133
|
tbl.insert(:name => 'Spitfire')
|
134
134
|
|
135
|
-
assert_equal([1, 'Spitfire', 300], tbl[1].to_a)
|
135
|
+
assert_equal([1, 'Spitfire', 300], tbl[1].to_a)
|
136
136
|
end
|
137
137
|
|
138
138
|
def test_insert_008
|
@@ -141,7 +141,7 @@ class TestTableLocal < Test::Unit::TestCase
|
|
141
141
|
t.encrypt = @encrypted }
|
142
142
|
tbl.insert('Spitfire', 500)
|
143
143
|
|
144
|
-
assert_equal([1, 'Spitfire', 500], tbl[1].to_a)
|
144
|
+
assert_equal([1, 'Spitfire', 500], tbl[1].to_a)
|
145
145
|
end
|
146
146
|
|
147
147
|
def test_insert_010
|
@@ -171,7 +171,7 @@ class TestTableLocal < Test::Unit::TestCase
|
|
171
171
|
tbl.insert('Spitfire', 500)
|
172
172
|
tbl.update(:speed => 495) { |r| r.recno == 1 }
|
173
173
|
|
174
|
-
assert_equal([1, 'Spitfire', 495], tbl[1].to_a)
|
174
|
+
assert_equal([1, 'Spitfire', 495], tbl[1].to_a)
|
175
175
|
end
|
176
176
|
|
177
177
|
def test_update_002
|
@@ -196,7 +196,7 @@ class TestTableLocal < Test::Unit::TestCase
|
|
196
196
|
tbl.insert('Spitfire', 500)
|
197
197
|
tbl[1] = {:speed => 495}
|
198
198
|
|
199
|
-
assert_equal([1, 'Spitfire', 495], tbl[1].to_a)
|
199
|
+
assert_equal([1, 'Spitfire', 495], tbl[1].to_a)
|
200
200
|
end
|
201
201
|
|
202
202
|
def test_update_005
|
@@ -240,7 +240,7 @@ class TestTableLocal < Test::Unit::TestCase
|
|
240
240
|
tbl.insert('Spitfire', 500)
|
241
241
|
tbl.delete { |r| r.recno == 1 }
|
242
242
|
|
243
|
-
assert_equal([], tbl[1].to_a)
|
243
|
+
assert_equal([], tbl[1].to_a)
|
244
244
|
end
|
245
245
|
|
246
246
|
def test_delete_002
|
@@ -249,7 +249,7 @@ class TestTableLocal < Test::Unit::TestCase
|
|
249
249
|
tbl.insert('Spitfire', 500)
|
250
250
|
tbl.delete { |r| r.name == 'Spitfire' }
|
251
251
|
|
252
|
-
assert_equal([], tbl[1].to_a)
|
252
|
+
assert_equal([], tbl[1].to_a)
|
253
253
|
end
|
254
254
|
|
255
255
|
def test_delete_003
|
@@ -259,7 +259,7 @@ class TestTableLocal < Test::Unit::TestCase
|
|
259
259
|
tbl.insert('P-51', 600)
|
260
260
|
tbl.delete { |r| r.recno == 1 }
|
261
261
|
|
262
|
-
assert_equal(1, tbl.select.size)
|
262
|
+
assert_equal(1, tbl.select.size)
|
263
263
|
end
|
264
264
|
|
265
265
|
def test_clear_001
|
@@ -269,7 +269,7 @@ class TestTableLocal < Test::Unit::TestCase
|
|
269
269
|
tbl.insert('P-51', 600)
|
270
270
|
tbl.clear
|
271
271
|
|
272
|
-
assert_equal(0, tbl.select.size)
|
272
|
+
assert_equal(0, tbl.select.size)
|
273
273
|
end
|
274
274
|
|
275
275
|
def test_clear_002
|
@@ -279,7 +279,7 @@ class TestTableLocal < Test::Unit::TestCase
|
|
279
279
|
tbl.insert('P-51', 600)
|
280
280
|
tbl.clear(true)
|
281
281
|
|
282
|
-
assert_equal(0, tbl.last_rec_no)
|
282
|
+
assert_equal(0, tbl.last_rec_no)
|
283
283
|
end
|
284
284
|
|
285
285
|
def test_clear_003
|
@@ -288,7 +288,7 @@ class TestTableLocal < Test::Unit::TestCase
|
|
288
288
|
tbl.insert('Spitfire', 500)
|
289
289
|
tbl.insert('P-51', 600)
|
290
290
|
|
291
|
-
assert_equal(2, tbl.delete_all)
|
291
|
+
assert_equal(2, tbl.delete_all)
|
292
292
|
end
|
293
293
|
|
294
294
|
def test_add_column_001
|
@@ -319,8 +319,8 @@ class TestTableLocal < Test::Unit::TestCase
|
|
319
319
|
tbl.add_column(:two, {:DataType => :Integer, :Index => 1})
|
320
320
|
tbl.insert('bob', 3)
|
321
321
|
tbl.insert('sue', 5)
|
322
|
-
|
323
|
-
assert_equal([2, 'sue', 5],
|
322
|
+
|
323
|
+
assert_equal([2, 'sue', 5],
|
324
324
|
tbl.select_by_two_index { |r| r.two > 4}.first.to_a)
|
325
325
|
end
|
326
326
|
|
@@ -331,12 +331,12 @@ class TestTableLocal < Test::Unit::TestCase
|
|
331
331
|
|
332
332
|
assert_equal([:recno, :one, :two, :three], tbl.field_names)
|
333
333
|
end
|
334
|
-
|
334
|
+
|
335
335
|
def test_drop_column_001
|
336
336
|
tbl = @db.create_table(:empty, :one, :String, :two, :Integer
|
337
337
|
) { |t| t.encrypt = @encrypted }
|
338
338
|
tbl.drop_column(:one)
|
339
|
-
|
339
|
+
|
340
340
|
assert_equal([:recno, :two], tbl.field_names)
|
341
341
|
end
|
342
342
|
|
@@ -344,18 +344,18 @@ class TestTableLocal < Test::Unit::TestCase
|
|
344
344
|
tbl = @db.create_table(:empty, :one, :String, :two, :Integer
|
345
345
|
) { |t| t.encrypt = @encrypted }
|
346
346
|
tbl.drop_column(:two)
|
347
|
-
|
347
|
+
|
348
348
|
assert_raise(RuntimeError) { tbl.drop_column(:three) }
|
349
349
|
end
|
350
350
|
|
351
351
|
def test_drop_column_003
|
352
|
-
tbl = @db.create_table(:empty, :one, {:DataType => :String,
|
352
|
+
tbl = @db.create_table(:empty, :one, {:DataType => :String,
|
353
353
|
:Index => 1}, :two, :Integer) { |t| t.encrypt = @encrypted }
|
354
354
|
tbl.drop_column(:one)
|
355
|
-
|
355
|
+
|
356
356
|
assert_raise(NoMethodError) { tbl.select_by_one_index { true } }
|
357
357
|
end
|
358
|
-
|
358
|
+
|
359
359
|
def test_rename_column_001
|
360
360
|
tbl = @db.create_table(:empty, :one, :String) { |t|
|
361
361
|
t.encrypt = @encrypted }
|
@@ -388,163 +388,163 @@ class TestTableLocal < Test::Unit::TestCase
|
|
388
388
|
tbl = @db.create_table(:empty, :one, :String) { |t|
|
389
389
|
t.encrypt = @encrypted }
|
390
390
|
tbl.change_column_type(:one, :Integer)
|
391
|
-
|
391
|
+
|
392
392
|
assert_equal([:Integer, :Integer], tbl.field_types)
|
393
393
|
end
|
394
|
-
|
394
|
+
|
395
395
|
def test_change_column_type_002
|
396
396
|
tbl = @db.create_table(:empty, :one, :String) { |t|
|
397
397
|
t.encrypt = @encrypted }
|
398
398
|
|
399
|
-
assert_raise(RuntimeError) {tbl.change_column_type(:one, :integer)}
|
399
|
+
assert_raise(RuntimeError) {tbl.change_column_type(:one, :integer)}
|
400
400
|
end
|
401
|
-
|
401
|
+
|
402
402
|
def test_change_column_type_003
|
403
403
|
tbl = @db.create_table(:empty, :one, { :DataType => :String,
|
404
404
|
:Required => true}) { |t| t.encrypt = @encrypted }
|
405
405
|
tbl.change_column_type(:one, :Integer)
|
406
|
-
|
407
|
-
assert_equal([[:Integer, :Integer], [false, true]],
|
406
|
+
|
407
|
+
assert_equal([[:Integer, :Integer], [false, true]],
|
408
408
|
[tbl.field_types, tbl.field_requireds])
|
409
409
|
end
|
410
|
-
|
410
|
+
|
411
411
|
def test_calculated_field_001
|
412
412
|
tbl = @db.create_table(:empty, :one, :Integer, :two, :Integer,
|
413
413
|
:three, { :DataType => :Integer, :Calculated => 'one + two' }
|
414
414
|
) { |t| t.encrypt = @encrypted }
|
415
415
|
tbl.insert(1, 2, nil)
|
416
|
-
|
417
|
-
assert_equal(3, tbl[1].three)
|
416
|
+
|
417
|
+
assert_equal(3, tbl[1].three)
|
418
418
|
end
|
419
419
|
|
420
420
|
def test_calculated_field_002
|
421
421
|
tbl = @db.create_table(:empty, :one, :Integer, :two, :Integer,
|
422
422
|
:three, { :DataType => :Integer, :Calculated => 'one + two' }
|
423
423
|
) { |t| t.encrypt = @encrypted }
|
424
|
-
|
425
|
-
assert_raise(ArgumentError) { tbl.insert(1, 2, 3) }
|
424
|
+
|
425
|
+
assert_raise(ArgumentError) { tbl.insert(1, 2, 3) }
|
426
426
|
end
|
427
427
|
|
428
428
|
def test_column_required_001
|
429
|
-
tbl = @db.create_table(:empty, :one, :String, :two,
|
429
|
+
tbl = @db.create_table(:empty, :one, :String, :two,
|
430
430
|
{:DataType => :String, :Required => true}) { |t|
|
431
431
|
t.encrypt = @encrypted }
|
432
|
-
|
433
|
-
assert_raise(ArgumentError) { tbl.insert('one', nil) }
|
432
|
+
|
433
|
+
assert_raise(ArgumentError) { tbl.insert('one', nil) }
|
434
434
|
end
|
435
435
|
|
436
436
|
def test_column_required_002
|
437
|
-
tbl = @db.create_table(:empty, :one, :String, :two,
|
437
|
+
tbl = @db.create_table(:empty, :one, :String, :two,
|
438
438
|
{:DataType => :String, :Required => true}) { |t|
|
439
439
|
t.encrypt = @encrypted }
|
440
|
-
|
441
|
-
assert_raise(ArgumentError) { tbl.insert(:one => 'one') }
|
440
|
+
|
441
|
+
assert_raise(ArgumentError) { tbl.insert(:one => 'one') }
|
442
442
|
end
|
443
443
|
|
444
444
|
def test_column_required_003
|
445
|
-
tbl = @db.create_table(:empty, :one, :String, :two,
|
445
|
+
tbl = @db.create_table(:empty, :one, :String, :two,
|
446
446
|
{:DataType => :String, :Required => false}) { |t|
|
447
447
|
t.encrypt = @encrypted }
|
448
|
-
tbl.insert(:one => 'one')
|
449
|
-
|
450
|
-
assert_equal([1, 'one', nil], tbl[1].to_a)
|
448
|
+
tbl.insert(:one => 'one')
|
449
|
+
|
450
|
+
assert_equal([1, 'one', nil], tbl[1].to_a)
|
451
451
|
end
|
452
452
|
|
453
453
|
def test_column_required_004
|
454
|
-
tbl = @db.create_table(:empty, :one, :String, :two,
|
454
|
+
tbl = @db.create_table(:empty, :one, :String, :two,
|
455
455
|
{:DataType => :String, :Required => true, :Default => 'bob'}
|
456
456
|
) { |t| t.encrypt = @encrypted }
|
457
|
-
tbl.insert(:one => 'one')
|
458
|
-
|
459
|
-
assert_equal([1, 'one', 'bob'], tbl[1].to_a)
|
457
|
+
tbl.insert(:one => 'one')
|
458
|
+
|
459
|
+
assert_equal([1, 'one', 'bob'], tbl[1].to_a)
|
460
460
|
end
|
461
461
|
|
462
462
|
def test_column_required_005
|
463
|
-
tbl = @db.create_table(:empty, :one, :String, :two,
|
463
|
+
tbl = @db.create_table(:empty, :one, :String, :two,
|
464
464
|
{:DataType => :String, :Required => true}) { |t|
|
465
465
|
t.encrypt = @encrypted }
|
466
|
-
tbl.insert('one', 'two')
|
467
|
-
|
466
|
+
tbl.insert('one', 'two')
|
467
|
+
|
468
468
|
assert_raise(ArgumentError) {
|
469
|
-
tbl.update('one', nil) { |r| r.recno == 1 } }
|
469
|
+
tbl.update('one', nil) { |r| r.recno == 1 } }
|
470
470
|
end
|
471
471
|
|
472
472
|
def test_column_required_006
|
473
|
-
tbl = @db.create_table(:empty, :one, :String, :two,
|
473
|
+
tbl = @db.create_table(:empty, :one, :String, :two,
|
474
474
|
{:DataType => :String, :Required => true}) { |t|
|
475
475
|
t.encrypt = @encrypted }
|
476
|
-
tbl.insert('one', 'two')
|
477
|
-
|
476
|
+
tbl.insert('one', 'two')
|
477
|
+
|
478
478
|
assert_raise(ArgumentError) {
|
479
|
-
tbl.update(:two => nil) { |r| r.recno == 1 } }
|
479
|
+
tbl.update(:two => nil) { |r| r.recno == 1 } }
|
480
480
|
end
|
481
481
|
|
482
482
|
def test_column_required_007
|
483
|
-
tbl = @db.create_table(:empty, :one, :String, :two,
|
483
|
+
tbl = @db.create_table(:empty, :one, :String, :two,
|
484
484
|
{:DataType => :String, :Required => true, :Default => 'three'}
|
485
485
|
) { |t| t.encrypt = @encrypted }
|
486
|
-
|
487
|
-
assert_raise(ArgumentError) { tbl.insert('one', nil) }
|
486
|
+
|
487
|
+
assert_raise(ArgumentError) { tbl.insert('one', nil) }
|
488
488
|
end
|
489
489
|
|
490
490
|
def test_change_column_required_001
|
491
491
|
tbl = @db.create_table(:empty, :one, :String, :two, :String
|
492
492
|
) { |t| t.encrypt = @encrypted }
|
493
493
|
tbl.change_column_required(:two, true)
|
494
|
-
|
495
|
-
assert_raise(ArgumentError) { tbl.insert(:one => 'one') }
|
494
|
+
|
495
|
+
assert_raise(ArgumentError) { tbl.insert(:one => 'one') }
|
496
496
|
end
|
497
497
|
|
498
498
|
def test_change_column_required_002
|
499
|
-
tbl = @db.create_table(:empty, :one, :String, :two,
|
499
|
+
tbl = @db.create_table(:empty, :one, :String, :two,
|
500
500
|
{:DataType => :String, :Required => true}) { |t|
|
501
501
|
t.encrypt = @encrypted }
|
502
502
|
tbl.change_column_required(:two, false)
|
503
|
-
|
504
|
-
assert_equal(1, tbl.insert(:one => 'one'))
|
503
|
+
|
504
|
+
assert_equal(1, tbl.insert(:one => 'one'))
|
505
505
|
end
|
506
506
|
|
507
507
|
def test_column_default_001
|
508
|
-
tbl = @db.create_table(:empty, :one, :String, :two,
|
508
|
+
tbl = @db.create_table(:empty, :one, :String, :two,
|
509
509
|
{:DataType => :String, :Default => 'two'}) { |t|
|
510
510
|
t.encrypt = @encrypted }
|
511
511
|
tbl.insert('one', nil)
|
512
|
-
assert_equal([1, 'one', nil], tbl[1].to_a)
|
512
|
+
assert_equal([1, 'one', nil], tbl[1].to_a)
|
513
513
|
end
|
514
514
|
|
515
515
|
def test_column_default_002
|
516
|
-
tbl = @db.create_table(:empty, :one, :String, :two,
|
516
|
+
tbl = @db.create_table(:empty, :one, :String, :two,
|
517
517
|
{:DataType => :String, :Default => 'two'}) { |t|
|
518
518
|
t.encrypt = @encrypted }
|
519
519
|
tbl.insert('one', 'not two')
|
520
520
|
|
521
|
-
assert_equal([1, 'one', 'not two'], tbl[1].to_a)
|
521
|
+
assert_equal([1, 'one', 'not two'], tbl[1].to_a)
|
522
522
|
end
|
523
523
|
|
524
524
|
def test_column_default_003
|
525
|
-
tbl = @db.create_table(:empty, :one, :String, :two,
|
525
|
+
tbl = @db.create_table(:empty, :one, :String, :two,
|
526
526
|
{:DataType => :String, :Default => 'two'}) { |t|
|
527
527
|
t.encrypt = @encrypted }
|
528
528
|
tbl.insert(:one => 'one')
|
529
529
|
|
530
|
-
assert_equal([1, 'one', 'two'], tbl[1].to_a)
|
530
|
+
assert_equal([1, 'one', 'two'], tbl[1].to_a)
|
531
531
|
end
|
532
532
|
|
533
533
|
def test_column_default_004
|
534
|
-
tbl = @db.create_table(:empty, :one, :String, :two,
|
534
|
+
tbl = @db.create_table(:empty, :one, :String, :two,
|
535
535
|
{:DataType => :String, :Default => 'two'}) { |t|
|
536
536
|
t.encrypt = @encrypted }
|
537
537
|
tbl.insert(Struct.new(:one, :two).new('one'))
|
538
538
|
|
539
|
-
assert_equal([1, 'one', nil], tbl[1].to_a)
|
539
|
+
assert_equal([1, 'one', nil], tbl[1].to_a)
|
540
540
|
end
|
541
541
|
|
542
542
|
def test_column_default_005
|
543
|
-
tbl = @db.create_table(:empty, :one, :String, :two,
|
543
|
+
tbl = @db.create_table(:empty, :one, :String, :two,
|
544
544
|
{:DataType => :String, :Default => 'two', :Required => true}) { |t|
|
545
545
|
t.encrypt = @encrypted }
|
546
546
|
|
547
|
-
assert_raise(ArgumentError) { tbl.insert('one', nil) }
|
547
|
+
assert_raise(ArgumentError) { tbl.insert('one', nil) }
|
548
548
|
end
|
549
549
|
|
550
550
|
def test_change_column_default_value_001
|
@@ -552,43 +552,43 @@ class TestTableLocal < Test::Unit::TestCase
|
|
552
552
|
) { |t| t.encrypt = @encrypted }
|
553
553
|
tbl.change_column_default_value(:two, 'two')
|
554
554
|
tbl.insert(:one => 'one')
|
555
|
-
|
556
|
-
assert_equal([1, 'one', 'two'], tbl[1].to_a)
|
555
|
+
|
556
|
+
assert_equal([1, 'one', 'two'], tbl[1].to_a)
|
557
557
|
end
|
558
558
|
|
559
559
|
def test_change_column_default_value_002
|
560
|
-
tbl = @db.create_table(:empty, :one, :String, :two,
|
560
|
+
tbl = @db.create_table(:empty, :one, :String, :two,
|
561
561
|
{:DataType => :String, :Default => 'two'}) { |t|
|
562
562
|
t.encrypt = @encrypted }
|
563
563
|
tbl.change_column_default_value(:two, nil)
|
564
564
|
tbl.insert(:one => 'one')
|
565
|
-
|
566
|
-
assert_equal([1, 'one', nil], tbl[1].to_a)
|
565
|
+
|
566
|
+
assert_equal([1, 'one', nil], tbl[1].to_a)
|
567
567
|
end
|
568
|
-
|
568
|
+
|
569
569
|
def test_index_001
|
570
570
|
tbl = @db.create_table(:empty, :one, {:DataType => :String,
|
571
571
|
:Index => 1}) { |t| t.encrypt = @encrypted }
|
572
572
|
tbl.insert('one')
|
573
573
|
tbl.insert('two')
|
574
|
-
|
574
|
+
|
575
575
|
assert_equal(1, tbl.select_by_one_index {|r| r.one == 'one'}.size)
|
576
576
|
end
|
577
|
-
|
577
|
+
|
578
578
|
def test_index_002
|
579
579
|
tbl = @db.create_table(:empty, :one, {:DataType => :String,
|
580
|
-
:Index => 1}, :two, :String, :three,
|
580
|
+
:Index => 1}, :two, :String, :three,
|
581
581
|
{:DataType => :Integer, :Index => 1}) { |t|
|
582
582
|
t.encrypt = @encrypted }
|
583
583
|
tbl.insert('one', 'two', 3)
|
584
584
|
tbl.insert('four', 'five', 6)
|
585
|
-
|
586
|
-
assert_equal(1, tbl.select_by_one_three_index {|r|
|
585
|
+
|
586
|
+
assert_equal(1, tbl.select_by_one_three_index {|r|
|
587
587
|
r.one == 'four' and r.three == 6}.size)
|
588
588
|
end
|
589
|
-
|
589
|
+
|
590
590
|
def test_index_003
|
591
|
-
assert_raise(RuntimeError) {@db.create_table(:empty, :one,
|
591
|
+
assert_raise(RuntimeError) {@db.create_table(:empty, :one,
|
592
592
|
{:DataType => :YAML, :Index => 1}) { |t| t.encrypt = @encrypted }}
|
593
593
|
end
|
594
594
|
|
@@ -597,8 +597,8 @@ class TestTableLocal < Test::Unit::TestCase
|
|
597
597
|
) { |t| t.encrypt = @encrypted }
|
598
598
|
tbl.insert('John', 'Doe')
|
599
599
|
tbl.add_index(:first, :last)
|
600
|
-
|
601
|
-
assert_equal(1, tbl.select_by_first_last_index {|r|
|
600
|
+
|
601
|
+
assert_equal(1, tbl.select_by_first_last_index {|r|
|
602
602
|
r.first == 'John' and r.last == 'Doe'}.size)
|
603
603
|
end
|
604
604
|
|
@@ -729,18 +729,18 @@ class TestTableLocal < Test::Unit::TestCase
|
|
729
729
|
|
730
730
|
class Foobar
|
731
731
|
attr_accessor(:recno, :one)
|
732
|
-
|
732
|
+
|
733
733
|
def Foobar.kb_create(recno, one)
|
734
734
|
Foobar.new do |x|
|
735
735
|
x.recno = recno
|
736
736
|
x.one = one
|
737
737
|
end
|
738
738
|
end
|
739
|
-
|
739
|
+
|
740
740
|
def initialize(&block)
|
741
741
|
instance_eval(&block)
|
742
742
|
end
|
743
|
-
end
|
743
|
+
end
|
744
744
|
|
745
745
|
def test_record_class_001
|
746
746
|
tbl = @db.create_table(:empty, :one, :String) {|t|
|
@@ -766,38 +766,38 @@ class TestTableLocal < Test::Unit::TestCase
|
|
766
766
|
tbl.update(:one => ['two', 3]) { |r| r.recno == 1 }
|
767
767
|
assert_equal(['two', 3], tbl[1].one)
|
768
768
|
end
|
769
|
-
|
769
|
+
|
770
770
|
def test_nil_values_001
|
771
771
|
tbl = @db.create_table(:nil_tests, :nil_value, :Integer,
|
772
772
|
:conditional, :Integer)
|
773
773
|
tbl.insert(nil, 100)
|
774
|
-
|
774
|
+
|
775
775
|
recs = []
|
776
|
-
|
776
|
+
|
777
777
|
assert_nothing_raised {rec = tbl.select {|r| r.nil_value > 100}}
|
778
|
-
assert_equal 0, recs.
|
779
|
-
|
780
|
-
assert_nothing_raised {recs = tbl.select {|r| r.nil_value > 100 and
|
778
|
+
assert_equal 0, recs.size
|
779
|
+
|
780
|
+
assert_nothing_raised {recs = tbl.select {|r| r.nil_value > 100 and
|
781
781
|
r.conditional > 100}}
|
782
|
-
assert_equal 0, recs.
|
782
|
+
assert_equal 0, recs.size
|
783
783
|
|
784
|
-
assert_nothing_raised {recs = tbl.select {|r| r.nil_value > 100 or
|
784
|
+
assert_nothing_raised {recs = tbl.select {|r| r.nil_value > 100 or
|
785
785
|
r.conditional > 100}}
|
786
|
-
assert_equal 0, recs.
|
786
|
+
assert_equal 0, recs.size
|
787
787
|
|
788
|
-
assert_nothing_raised {recs = tbl.select {|r| r.nil_value > 100 and
|
788
|
+
assert_nothing_raised {recs = tbl.select {|r| r.nil_value > 100 and
|
789
789
|
r.conditional == 100}}
|
790
|
-
assert_equal 0, recs.
|
790
|
+
assert_equal 0, recs.size
|
791
791
|
|
792
|
-
assert_nothing_raised {recs = tbl.select {|r| r.nil_value > 100 or
|
792
|
+
assert_nothing_raised {recs = tbl.select {|r| r.nil_value > 100 or
|
793
793
|
r.conditional == 100}}
|
794
|
-
assert_equal 1, recs.
|
794
|
+
assert_equal 1, recs.size
|
795
795
|
|
796
796
|
assert_nothing_raised {recs = tbl.select {|r| r.nil_value.kb_nil?}}
|
797
|
-
assert_equal 1, recs.
|
797
|
+
assert_equal 1, recs.size
|
798
798
|
|
799
799
|
assert_nothing_raised {recs = tbl.select {|r| r.nil_value == kb_nil}}
|
800
|
-
assert_equal 1, recs.
|
800
|
+
assert_equal 1, recs.size
|
801
801
|
end
|
802
802
|
end
|
803
803
|
|