odba 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 16603b53ff650531c5033f59fe10a783862af1be
4
- data.tar.gz: 585862c143d0afd37d098fb2909a8687649fd983
2
+ SHA256:
3
+ metadata.gz: 8eeea954899332aa488838e1af1f1aff8d9b4a228efb1a83fbe7d800518d4fb7
4
+ data.tar.gz: 3ff0033e77a3737f63279be8f55045495268372a86c9c24a59ffbf60df46252f
5
5
  SHA512:
6
- metadata.gz: ece100e608273736d4b6ad5c1652dd25a0788eb53320e85c1fcc794fe9ff0a7e63b18527147a7c4f763a14692dc6b0e5c8d440842bd39b4187d5af5521920855
7
- data.tar.gz: 4aee8414f90279ae66fe63f90e37cd1ff648c01131589d71ad7c9c59be5747d9a7e801d5de03e2c9a0ddd1a281606f32e5d450d20c3ba28a860eae1524e80f41
6
+ metadata.gz: 6f2141814522c6e0f7e01b71cc4a826abfb5172a6abfb423d871033d804aeea63db8febecfa3252c08591af4e77bcb0efc3eabfad8f85dd88b1b2e704fa50ff3
7
+ data.tar.gz: 1e9a12681a46bc3fa6154350af97f7abd8bc065d1ffa4ede3af8419209139433b21e5d5b3afb844599758b015f77d1b86abbd96d1913e209f2979e198be0fd60
data/Gemfile CHANGED
@@ -2,16 +2,10 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- group 'test' do
6
- gem 'flexmock', "~> 1.3.0"
7
- gem 'test-unit'
8
- gem 'minitest'
9
- end
10
-
11
5
  group 'debugger' do
12
6
  gem 'pry'
13
7
  gem 'pry-nav'
14
8
  gem 'pry-rescue'
15
9
  gem 'pry-stack_explorer'
16
10
  gem 'pry-doc'
17
- end
11
+ end
@@ -1,3 +1,7 @@
1
+ === 1.1.6 / 23.01.2016
2
+
3
+ * Updated to use ydbi 0.5.6
4
+
1
5
  === 1.1.5 / 23.01.2016
2
6
 
3
7
  * Remove unused parameter dict for update_fulltext_index
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  class Odba
4
- VERSION = '1.1.5'
4
+ VERSION = '1.1.6'
5
5
  end
@@ -16,13 +16,15 @@ Gem::Specification.new do |spec|
16
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
17
  spec.require_paths = ["lib"]
18
18
 
19
- spec.add_dependency 'ydbi', '>=0.5.1'
20
- spec.add_dependency 'ydbd-pg','>=0.5.1'
19
+ spec.add_dependency 'ydbi', '>=0.5.6'
20
+ spec.add_dependency 'ydbd-pg','>=0.5.6'
21
21
 
22
22
  spec.add_development_dependency "bundler"
23
23
  spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec"
24
25
  spec.add_development_dependency "flexmock"
26
+ spec.add_development_dependency "minitest"
27
+ spec.add_development_dependency "test-unit"
28
+ spec.add_development_dependency "debug_inspector"
25
29
  spec.add_development_dependency "simplecov", '>= 0.14.1'
26
- spec.add_development_dependency "minitest" if /^1\./.match(RUBY_VERSION)
27
30
  end
28
-
File without changes
@@ -5,6 +5,7 @@ $: << File.dirname(__FILE__)
5
5
  $: << File.expand_path('../lib', File.dirname(__FILE__))
6
6
 
7
7
  require 'minitest/autorun'
8
+ require 'flexmock/test_unit'
8
9
  require 'flexmock'
9
10
  require 'odba/persistable'
10
11
  require 'odba/stub'
@@ -6,6 +6,7 @@ $: << File.dirname(__FILE__)
6
6
  $: << File.expand_path('../lib/', File.dirname(__FILE__))
7
7
 
8
8
  require 'minitest/autorun'
9
+ require 'flexmock/test_unit'
9
10
  require 'flexmock'
10
11
  require 'odba/cache'
11
12
  require 'odba/cache_entry'
@@ -5,6 +5,7 @@ $: << File.dirname(__FILE__)
5
5
  $: << File.expand_path("../lib", File.dirname(__FILE__))
6
6
 
7
7
  require 'minitest/autorun'
8
+ require 'flexmock/test_unit'
8
9
  require 'flexmock'
9
10
  require 'odba/cache_entry'
10
11
  require 'odba/odba'
@@ -4,6 +4,7 @@
4
4
  $: << File.expand_path('../lib', File.dirname(__FILE__))
5
5
 
6
6
  require 'minitest/autorun'
7
+ require 'flexmock/test_unit'
7
8
  require 'flexmock'
8
9
  require 'odba/connection_pool'
9
10
  ## connection_pool requires 'dbi', which unshifts the site_ruby dir
@@ -4,8 +4,9 @@
4
4
  $: << File.expand_path('../lib', File.dirname(__FILE__))
5
5
 
6
6
  require 'minitest/autorun'
7
- require 'odba/drbwrapper'
7
+ require 'flexmock/test_unit'
8
8
  require 'flexmock'
9
+ require 'odba/drbwrapper'
9
10
 
10
11
  module ODBA
11
12
  class TestDRbWrapper < Minitest::Test
@@ -4,11 +4,12 @@
4
4
  $: << File.dirname(__FILE__)
5
5
  $: << File.expand_path('../lib/', File.dirname(__FILE__))
6
6
 
7
+ require 'minitest/autorun'
8
+ require 'flexmock/test_unit'
9
+ require 'flexmock'
7
10
  require 'odba/persistable'
8
11
  require 'odba/stub'
9
12
  require 'odba/odba'
10
- require 'minitest/autorun'
11
- require 'flexmock'
12
13
 
13
14
  module ODBA
14
15
  class TestHash < Minitest::Test
@@ -5,6 +5,7 @@ $: << File.dirname(__FILE__)
5
5
  $: << File.expand_path('../lib', File.dirname(__FILE__))
6
6
 
7
7
  require 'minitest/autorun'
8
+ require 'flexmock/test_unit'
8
9
  require 'flexmock'
9
10
  require 'odba/id_server'
10
11
  require 'odba/odba'
@@ -5,10 +5,11 @@ $: << File.dirname(__FILE__)
5
5
  $: << File.expand_path("../lib", File.dirname(__FILE__))
6
6
 
7
7
  require 'minitest/autorun'
8
+ require 'flexmock/test_unit'
9
+ require 'flexmock'
8
10
  require 'odba/index'
9
11
  require 'odba/index_definition'
10
12
  require 'odba/odba'
11
- require 'flexmock'
12
13
 
13
14
  module ODBA
14
15
  class Origin
@@ -310,7 +311,6 @@ module ODBA
310
311
  ODBA.storage = @storage
311
312
  df = IndexDefinition.new
312
313
  df.index_name = 'index'
313
- df.dictionary = 'german'
314
314
  df.origin_klass = :Origin
315
315
  df.target_klass = :Target
316
316
  df.resolve_origin = :origin
@@ -320,12 +320,12 @@ module ODBA
320
320
  def test_fetch_ids
321
321
  rows = [[1,3], [2,2], [3,1]]
322
322
  @storage.should_receive(:retrieve_from_fulltext_index)\
323
- .with('index', 'search-term', 'german', false).and_return rows
323
+ .with('index', 'search-term', false).and_return rows
324
324
  assert_equal([1,2,3], @index.fetch_ids('search-term'))
325
325
  end
326
326
  def test_do_update_index
327
327
  @storage.should_receive(:update_fulltext_index)\
328
- .with('index', 3, 'some full text', 4, 'german')
328
+ .with('index', 3, 'some full text', 4)
329
329
  @index.do_update_index(3, 'some full text', 4)
330
330
  end
331
331
  def test_update_target
@@ -334,9 +334,9 @@ module ODBA
334
334
  @storage.should_receive(:fulltext_index_delete)\
335
335
  .with('index', 4, 'target_id')
336
336
  @storage.should_receive(:update_fulltext_index)\
337
- .with('index', 1, 'fulltext term', 4, 'german')
337
+ .with('index', 1, 'fulltext term', 4)
338
338
  @storage.should_receive(:update_fulltext_index)\
339
- .with('index', 2, 'fulltext term', 4, 'german')
339
+ .with('index', 2, 'fulltext term', 4)
340
340
  target = Target.new
341
341
  target.odba_id = 4
342
342
  origin1 = Origin.new
@@ -356,9 +356,9 @@ module ODBA
356
356
  @storage.should_receive(:fulltext_index_delete)\
357
357
  .times(1).with('index', 1, 'origin_id')
358
358
  @storage.should_receive(:update_fulltext_index)\
359
- .times(1).with('index', 1, 'fulltext term', 4, 'german')
359
+ .times(1).with('index', 1, 'fulltext term', 4)
360
360
  @storage.should_receive(:update_fulltext_index)\
361
- .times(1).with('index', 1, 'fulltext term', 5, 'german')
361
+ .times(1).with('index', 1, 'fulltext term', 5)
362
362
  target = Target.new
363
363
  target.odba_id = 4
364
364
  origin1 = Origin.new
@@ -3,6 +3,8 @@
3
3
  $: << File.expand_path('../lib', File.dirname(__FILE__))
4
4
 
5
5
  require 'minitest/autorun'
6
+ require 'flexmock/test_unit'
7
+ require 'flexmock'
6
8
  require 'odba/marshal'
7
9
 
8
10
  module ODBA
@@ -4,14 +4,15 @@
4
4
  $: << File.dirname(__FILE__)
5
5
  $: << File.expand_path('../lib/', File.dirname(__FILE__))
6
6
 
7
+ require 'minitest/autorun'
8
+ require 'flexmock/test_unit'
9
+ require 'flexmock'
7
10
  require 'odba/persistable'
8
11
  require 'odba/stub'
9
12
  require 'odba/cache'
10
13
  require 'odba/odba'
11
14
  require 'odba/storage'
12
15
  require 'odba/marshal'
13
- require 'minitest/autorun'
14
- require 'flexmock'
15
16
  require 'yaml'
16
17
 
17
18
  module ODBA
@@ -5,9 +5,10 @@
5
5
  $: << File.dirname(__FILE__)
6
6
  $: << File.expand_path('../lib/', File.dirname(__FILE__))
7
7
 
8
- require 'odba/storage'
9
8
  require 'minitest/autorun'
9
+ require 'flexmock/test_unit'
10
10
  require 'flexmock'
11
+ require 'odba/storage'
11
12
 
12
13
  module ODBA
13
14
  class Storage
@@ -40,25 +41,25 @@ module ODBA
40
41
  expected1 = <<-SQL
41
42
  DELETE FROM object_connection WHERE origin_id = ?
42
43
  SQL
43
- dbi.should_receive(:do).with(expected1, 2).times(1).and_return do
44
+ dbi.should_receive(:do).once.with(expected1, 2).times(1).and_return do
44
45
  assert true
45
46
  end
46
47
  expected2 = <<-SQL
47
48
  DELETE FROM object_connection WHERE target_id = ?
48
49
  SQL
49
- dbi.should_receive(:do).with(expected2, 2).times(1).and_return do
50
+ dbi.should_receive(:do).once.with(expected2, 2).times(1).and_return do
50
51
  assert true
51
52
  end
52
53
  expected3 = <<-SQL
53
54
  DELETE FROM collection WHERE odba_id = ?
54
55
  SQL
55
- dbi.should_receive(:do).with(expected3, 2).times(1).and_return do
56
+ dbi.should_receive(:do).once.with(expected3, 2).times(1).and_return do
56
57
  assert true
57
58
  end
58
59
  expected4 = <<-SQL
59
60
  DELETE FROM object WHERE odba_id = ?
60
61
  SQL
61
- dbi.should_receive(:do).with(expected4, 2).times(1).and_return do
62
+ dbi.should_receive(:do).once.with(expected4, 2).times(1).and_return do
62
63
  assert true
63
64
  end
64
65
  @storage.delete_persistable(2)
@@ -83,36 +84,25 @@ module ODBA
83
84
  dbi = flexmock('dbi')
84
85
  @storage.dbi = dbi
85
86
  sql = <<-SQL
86
- CREATE TABLE index_name (
87
- origin_id INTEGER,
88
- search_term TEXT,
89
- target_id INTEGER
90
- );
91
- SQL
92
- dbi.should_receive(:do).times(1).with(sql).and_return do
93
- assert true
94
- end
95
- sql = <<-SQL
96
- CREATE INDEX origin_id_index_name
87
+ CREATE INDEX IF NOT EXISTS origin_id_index_name
97
88
  ON index_name(origin_id)
98
89
  SQL
99
90
  dbi.should_receive(:do).times(1).with(sql).and_return do
100
91
  assert true
101
92
  end
102
93
  sql = <<-SQL
103
- CREATE INDEX search_term_index_name
94
+ CREATE INDEX IF NOT EXISTS search_term_index_name
104
95
  ON index_name(search_term)
105
96
  SQL
106
97
  dbi.should_receive(:do).times(1).with(sql).and_return do
107
98
  assert true
108
99
  end
109
- sql = <<-SQL
110
- CREATE INDEX target_id_index_name
111
- ON index_name(target_id)
112
- SQL
113
- dbi.should_receive(:do).times(1).with(sql).and_return do
114
- assert true
115
- end
100
+ sql = " DROP TABLE IF EXISTS index_name;\n"
101
+ dbi.should_receive(:do).once.with(sql)
102
+ sql = " CREATE INDEX IF NOT EXISTS target_id_index_name\n ON index_name(target_id)\n"
103
+ dbi.should_receive(:do).once.with(sql)
104
+ sql = " CREATE TABLE IF NOT EXISTS index_name (\n origin_id INTEGER,\n search_term TEXT,\n target_id INTEGER\n ) WITH OIDS;\n"
105
+ dbi.should_receive(:do).once.with(sql)
116
106
  @storage.create_index("index_name")
117
107
  end
118
108
  def test_next_id
@@ -295,7 +285,7 @@ module ODBA
295
285
  WHERE origin_id=?
296
286
  SQL
297
287
  handle = flexmock('StatementHandle')
298
- @dbi.should_receive(:do).with(sql, 'term', 2).times(1).and_return do
288
+ @dbi.should_receive(:do).once.with(sql, 'term', 2).times(1).and_return do
299
289
  assert true
300
290
  end
301
291
  @storage.update_index("index", 2, "term", nil)
@@ -334,7 +324,7 @@ module ODBA
334
324
  AND search_term = ?
335
325
  AND target_id = ?
336
326
  SQL
337
- dbi.should_receive(:do).with(sql, 6, 'search-term', 5).times(1).and_return do
327
+ dbi.should_receive(:do).once.with(sql, 6, 'search-term', 5).times(1).and_return do
338
328
  assert true
339
329
  end
340
330
  @storage.index_delete_target("foo_index", 6, 'search-term', 5)
@@ -342,8 +332,8 @@ module ODBA
342
332
  def test_drop_index
343
333
  dbi = flexmock("dbi")
344
334
  @storage.dbi = dbi
345
- sql = "DROP TABLE foo_index"
346
- dbi.should_receive(:do).with(sql).and_return do
335
+ sql = "DROP TABLE IF EXISTS foo_index"
336
+ dbi.should_receive(:do).once.with(sql).and_return do
347
337
  assert true
348
338
  end
349
339
  @storage.drop_index("foo_index")
@@ -393,7 +383,7 @@ module ODBA
393
383
  DELETE FROM object_connection
394
384
  WHERE origin_id = ? AND target_id IN (7,9)
395
385
  SQL
396
- dbi.should_receive(:do).with(sql, 123).and_return {
386
+ dbi.should_receive(:do).once.with(sql, 123).and_return {
397
387
  assert(true)
398
388
  }
399
389
  sql = <<-SQL
@@ -428,73 +418,53 @@ module ODBA
428
418
  [:bar, 'Date'],
429
419
  ]
430
420
  sql = <<-'SQL'
431
- CREATE TABLE conditions (
421
+ CREATE TABLE IF NOT EXISTS conditions (
432
422
  origin_id INTEGER,
433
423
  foo Integer,
434
424
  bar Date,
435
425
  target_id INTEGER
436
426
  );
437
427
  SQL
438
- @dbi.should_receive(:do).with(sql).and_return do
428
+ @dbi.should_receive(:do).once.with(sql).and_return do
439
429
  assert true
440
430
  end
441
431
  sql = <<-'SQL'
442
- CREATE INDEX origin_id_conditions ON conditions(origin_id);
432
+ CREATE INDEX IF NOT EXISTS origin_id_conditions ON conditions(origin_id);
443
433
  SQL
444
- @dbi.should_receive(:do).with(sql).and_return do
434
+ @dbi.should_receive(:do).once.with(sql).and_return do
445
435
  assert true
446
436
  end
447
437
  sql = <<-'SQL'
448
- CREATE INDEX foo_conditions ON conditions(foo);
438
+ CREATE INDEX IF NOT EXISTS foo_conditions ON conditions(foo);
449
439
  SQL
450
- @dbi.should_receive(:do).with(sql).and_return do
440
+ @dbi.should_receive(:do).once.with(sql).and_return do
451
441
  assert true
452
442
  end
453
443
  sql = <<-'SQL'
454
- CREATE INDEX bar_conditions ON conditions(bar);
444
+ CREATE INDEX IF NOT EXISTS bar_conditions ON conditions(bar);
455
445
  SQL
456
- @dbi.should_receive(:do).with(sql).and_return do
446
+ @dbi.should_receive(:do).once.with(sql).and_return do
457
447
  assert true
458
448
  end
459
449
  sql = <<-'SQL'
460
- CREATE INDEX target_id_conditions ON conditions(target_id);
450
+ CREATE INDEX IF NOT EXISTS target_id_conditions ON conditions(target_id);
461
451
  SQL
462
- @dbi.should_receive(:do).with(sql).and_return do
452
+ @dbi.should_receive(:do).once.with(sql).and_return do
463
453
  assert true
464
454
  end
465
455
  @storage.create_condition_index('conditions', definition)
466
456
  end
467
457
  def test_create_fulltext_index
468
- sql = <<-'SQL'
469
- CREATE TABLE fulltext (
470
- origin_id INTEGER,
471
- search_term tsvector,
472
- target_id INTEGER
473
- );
474
- SQL
475
458
  statement = flexmock('StatementHandle')
476
- @dbi.should_receive(:do).with(sql).and_return do
477
- assert true
478
- end
479
- sql = <<-'SQL'
480
- CREATE INDEX origin_id_fulltext ON fulltext(origin_id);
481
- SQL
482
- @dbi.should_receive(:do).with(sql).and_return do
483
- assert true
484
- end
485
- sql = <<-'SQL'
486
- CREATE INDEX search_term_fulltext
487
- ON fulltext USING gist(search_term);
488
- SQL
489
- @dbi.should_receive(:do).with(sql).and_return do
490
- assert true
491
- end
492
- sql = <<-'SQL'
493
- CREATE INDEX target_id_fulltext ON fulltext(target_id);
494
- SQL
495
- @dbi.should_receive(:do).with(sql).and_return do
496
- assert true
497
- end
459
+ @dbi.should_receive(:do).once.with("DROP TABLE IF EXISTS fulltext;\n")
460
+ sql = "CREATE INDEX IF NOT EXISTS origin_id_fulltext ON fulltext(origin_id);\n"
461
+ @dbi.should_receive(:do).once.with(sql).and_return
462
+ sql = "CREATE INDEX IF NOT EXISTS target_id_fulltext ON fulltext(target_id);\n"
463
+ @dbi.should_receive(:do).once.with(sql).and_return
464
+ sql = "CREATE TABLE IF NOT EXISTS fulltext (\n origin_id INTEGER,\n search_term tsvector,\n target_id INTEGER\n) WITH OIDS ;\n"
465
+ @dbi.should_receive(:do).once.with(sql).and_return
466
+ sql = "CREATE INDEX IF NOT EXISTS search_term_fulltext\nON fulltext USING gist(search_term);\n"
467
+ @dbi.should_receive(:do).once.with(sql).and_return
498
468
  @storage.create_fulltext_index('fulltext')
499
469
  end
500
470
  def test_extent_ids
@@ -523,7 +493,7 @@ CREATE INDEX target_id_fulltext ON fulltext(target_id);
523
493
  WHERE odba_id = ? AND key = ?
524
494
  SQL
525
495
  statement = flexmock('StatementHandle')
526
- @dbi.should_receive(:do).with(sql, 34, 'key_dump').and_return do
496
+ @dbi.should_receive(:do).once.with(sql, 34, 'key_dump').and_return do
527
497
  assert true
528
498
  end
529
499
  @storage.collection_remove(34, "key_dump")
@@ -534,7 +504,7 @@ CREATE INDEX target_id_fulltext ON fulltext(target_id);
534
504
  VALUES (?, ?, ?)
535
505
  SQL
536
506
  statement = flexmock('StatementHandle')
537
- @dbi.should_receive(:do).with(sql, 34, 'key_dump', 'dump').and_return do
507
+ @dbi.should_receive(:do).once.with(sql, 34, 'key_dump', 'dump').and_return do
538
508
  assert true
539
509
  end
540
510
  @storage.collection_store(34, "key_dump", 'dump')
@@ -606,13 +576,13 @@ CREATE INDEX target_id_fulltext ON fulltext(target_id);
606
576
  tables = %w{object_connection collection}
607
577
  @dbi.should_receive(:tables).and_return(tables)
608
578
  sql = <<-'SQL'
609
- CREATE TABLE object (
579
+ CREATE TABLE IF NOT EXISTS object (
610
580
  odba_id INTEGER NOT NULL, content TEXT,
611
581
  name TEXT, prefetchable BOOLEAN, extent TEXT,
612
582
  PRIMARY KEY(odba_id), UNIQUE(name)
613
583
  );
614
- CREATE INDEX prefetchable_index ON object(prefetchable);
615
- CREATE INDEX extent_index ON object(extent);
584
+ CREATE INDEX IF NOT EXISTS prefetchable_index ON object(prefetchable);
585
+ CREATE INDEX IF NOT EXISTS extent_index ON object(extent);
616
586
  SQL
617
587
  @dbi.should_receive(:execute).with(sql).and_return {
618
588
  assert(true) }
@@ -625,11 +595,11 @@ CREATE INDEX extent_index ON object(extent);
625
595
  tables = %w{object collection}
626
596
  @dbi.should_receive(:tables).and_return(tables)
627
597
  sql = <<-'SQL'
628
- CREATE TABLE object_connection (
598
+ CREATE TABLE IF NOT EXISTS object_connection (
629
599
  origin_id integer, target_id integer,
630
600
  PRIMARY KEY(origin_id, target_id)
631
601
  );
632
- CREATE INDEX target_id_index ON object_connection(target_id);
602
+ CREATE INDEX IF NOT EXISTS target_id_index ON object_connection(target_id);
633
603
  SQL
634
604
  @dbi.should_receive(:execute).with(sql).and_return {
635
605
  assert(true) }
@@ -642,7 +612,7 @@ CREATE INDEX target_id_index ON object_connection(target_id);
642
612
  tables = %w{object object_connection}
643
613
  @dbi.should_receive(:tables).and_return(tables)
644
614
  sql = <<-'SQL'
645
- CREATE TABLE collection (
615
+ CREATE TABLE IF NOT EXISTS collection (
646
616
  odba_id integer NOT NULL, key text, value text,
647
617
  PRIMARY KEY(odba_id, key)
648
618
  );
@@ -657,24 +627,13 @@ CREATE TABLE collection (
657
627
  def test_setup__extent
658
628
  tables = %w{object object_connection collection}
659
629
  @dbi.should_receive(:tables).and_return(tables)
660
- sql = "CREATE TABLE object (\n odba_id INTEGER NOT NULL, content TEXT,\n name TEXT, prefetchable BOOLEAN, extent TEXT,\n PRIMARY KEY(odba_id), UNIQUE(name)\n);\n"
661
- @dbi.should_receive(:do).with(sql).and_return(true)
662
- sql = "CREATE INDEX prefetchable_index ON object(prefetchable);\n"
663
- @dbi.should_receive(:do).with(sql).and_return(true)
664
- sql = "CREATE INDEX extent_index ON object(extent);\n"
665
- @dbi.should_receive(:do).with(sql).and_return(true)
666
- sql = "CREATE TABLE object_connection (\n origin_id integer, target_id integer,\n PRIMARY KEY(origin_id, target_id)\n);\n"
667
- @dbi.should_receive(:do).with(sql).and_return(true)
668
- sql = "CREATE INDEX target_id_index ON object_connection(target_id);\n"
669
- @dbi.should_receive(:do).with(sql).and_return(true)
670
- sql = "CREATE TABLE collection (\n odba_id integer NOT NULL, key text, value text,\n PRIMARY KEY(odba_id, key)\n);\n"
671
- @dbi.should_receive(:do).with(sql).and_return(true)
672
- sql = <<-'SQL'
673
- ALTER TABLE object ADD COLUMN extent TEXT;
674
- CREATE INDEX extent_index ON object(extent);
675
- SQL
676
- @dbi.should_receive(:do).with(sql).and_return {
677
- assert(true) }
630
+ sql = "CREATE TABLE IF NOT EXISTS object_connection (\n origin_id integer, target_id integer,\n PRIMARY KEY(origin_id, target_id)\n);\n"
631
+ @dbi.should_receive(:do).once.with(sql).and_return(true)
632
+ sql = "CREATE INDEX IF NOT EXISTS target_id_index ON object_connection(target_id);\n"
633
+ @dbi.should_receive(:do).once.with(sql).and_return(true)
634
+ sql = "CREATE TABLE IF NOT EXISTS collection (\n odba_id integer NOT NULL, key text, value text,\n PRIMARY KEY(odba_id, key)\n);\n"
635
+ @dbi.should_receive(:do).once.with(sql).and_return(true)
636
+ @dbi.should_receive(:do).once.with("ALTER TABLE object ADD COLUMN extent TEXT;\nCREATE INDEX IF NOT EXISTS extent_index ON object(extent);\n")
678
637
  @dbi.should_receive(:columns).and_return([])
679
638
  @storage.setup
680
639
  end
@@ -684,7 +643,7 @@ CREATE INDEX extent_index ON object(extent);
684
643
  INSERT INTO index (origin_id, target_id, foo, bar)
685
644
  VALUES (?, ?, ?, ?)
686
645
  SQL
687
- @dbi.should_receive(:do).with(sql, 12, 15, 14, 'blur').times(1).and_return {
646
+ @dbi.should_receive(:do).once.with(sql, 12, 15, 14, 'blur').times(1).and_return {
688
647
  assert(true)
689
648
  }
690
649
  terms = [
@@ -699,7 +658,7 @@ VALUES (?, ?, ?, ?)
699
658
  UPDATE index SET foo=?, bar=?
700
659
  WHERE origin_id = ?
701
660
  SQL
702
- @dbi.should_receive(:do).with(sql, 14, 'blur', 12).times(1).and_return {
661
+ @dbi.should_receive(:do).once.with(sql, 14, 'blur', 12).times(1).and_return {
703
662
  assert(true)
704
663
  }
705
664
  terms = [
@@ -710,29 +669,17 @@ WHERE origin_id = ?
710
669
  end
711
670
  def test_update_fulltext_index__with_target_id
712
671
  handle = flexmock('StatementHandle')
713
- sql = <<-'SQL'
714
- INSERT INTO index (origin_id, search_term, target_id)
715
- VALUES (?, to_tsvector(?, ?), ?)
716
- SQL
717
- @dbi.should_receive(:do).with(sql, 12, "german", "some text",
718
- 15).and_return {
719
- assert(true)
720
- }
721
- @storage.update_fulltext_index('index', 12, "some text", 15,
722
- 'german')
672
+ sql = "INSERT INTO index (origin_id, search_term, target_id)\nVALUES (?, to_tsvector(?), ?)\n"
673
+ @dbi.should_receive(:do).once.with(sql, "12", "some text", 15)
674
+ @storage.update_fulltext_index('index', 12, "some text", 15)
723
675
  end
724
676
  def test_update_fulltext_index__without_target_id
725
677
  handle = flexmock('StatementHandle')
726
- sql = <<-'SQL'
727
- UPDATE index SET search_term=to_tsvector(?, ?)
728
- WHERE origin_id=?
729
- SQL
730
- @dbi.should_receive(:do).with(sql, "german", "some text",
731
- 12).and_return {
678
+ sql = "UPDATE index SET search_term=to_tsvector(?)\nWHERE origin_id=?\n"
679
+ @dbi.should_receive(:do).once.with(sql, "some text", 12).and_return {
732
680
  assert(true)
733
681
  }
734
- @storage.update_fulltext_index('index', 12, "some text", nil,
735
- 'german')
682
+ @storage.update_fulltext_index('index', 12, "some text", nil)
736
683
  end
737
684
  def test_condition_index_delete
738
685
  sql = <<-SQL
@@ -740,10 +687,10 @@ DELETE FROM index WHERE origin_id = ? AND c1 = ? AND c2 = ?
740
687
  SQL
741
688
  if /^1\.8/.match(RUBY_VERSION)
742
689
  sql = "DELETE FROM index WHERE origin_id = ? AND c2 = ? AND c1 = ?"
743
- @dbi.should_receive(:do).with(sql.chomp, 3, 7, 'f').times(1).and_return(true)
690
+ @dbi.should_receive(:do).once.with(sql.chomp, 3, 7, 'f').times(1).and_return(true)
744
691
  else
745
692
  sql = "DELETE FROM index WHERE origin_id = ? AND c1 = ? AND c2 = ?"
746
- @dbi.should_receive(:do).with(sql.chomp, 3, 'f', 7).times(1).and_return(true)
693
+ @dbi.should_receive(:do).once.with(sql.chomp, 3, 'f', 7).times(1).and_return(true)
747
694
  end
748
695
  handle = flexmock('DBHandle')
749
696
  @storage.condition_index_delete('index', 3, {'c1' => 'f','c2' => 7})
@@ -752,10 +699,10 @@ DELETE FROM index WHERE origin_id = ? AND c1 = ? AND c2 = ?
752
699
  handle = flexmock('DBHandle')
753
700
  if /^1\.8/.match(RUBY_VERSION)
754
701
  sql = "DELETE FROM index WHERE origin_id = ? AND c2 = ? AND c1 = ? AND target_id = ?"
755
- @dbi.should_receive(:do).with(sql.chomp, 3, 7, 'f', 4).times(1).and_return(true)
702
+ @dbi.should_receive(:do).once.with(sql.chomp, 3, 7, 'f', 4).times(1).and_return(true)
756
703
  else
757
704
  sql = "DELETE FROM index WHERE origin_id = ? AND c1 = ? AND c2 = ? AND target_id = ?"
758
- @dbi.should_receive(:do).with(sql.chomp, 3, 'f', 7, 4).times(1).and_return(true)
705
+ @dbi.should_receive(:do).once.with(sql.chomp, 3, 'f', 7, 4).times(1).and_return(true)
759
706
  end
760
707
  @storage.condition_index_delete('index', 3, {'c1' => 'f','c2' => 7}, 4)
761
708
  end
@@ -781,7 +728,7 @@ DELETE FROM index WHERE origin_id = ? AND c1 = ? AND c2 = ?
781
728
  end
782
729
  def test_ensure_target_id_index
783
730
  sql = <<-SQL
784
- CREATE INDEX target_id_index
731
+ CREATE INDEX IF NOT EXISTS target_id_index
785
732
  ON index(target_id)
786
733
  SQL
787
734
  @dbi.should_receive(:execute).with(sql).and_return {
@@ -793,7 +740,7 @@ DELETE FROM index WHERE origin_id = ? AND c1 = ? AND c2 = ?
793
740
  DELETE FROM index
794
741
  WHERE origin_id = ?
795
742
  SQL
796
- @dbi.should_receive(:do).with(sql, 4)\
743
+ @dbi.should_receive(:do).once.with(sql, 4)\
797
744
  .times(1).and_return { assert(true) }
798
745
  @storage.fulltext_index_delete('index', 4, 'origin_id')
799
746
  end
@@ -802,7 +749,7 @@ DELETE FROM index WHERE origin_id = ? AND c1 = ? AND c2 = ?
802
749
  DELETE FROM index
803
750
  WHERE target_id = ?
804
751
  SQL
805
- @dbi.should_receive(:do).with(sql, 4)\
752
+ @dbi.should_receive(:do).once.with(sql, 4)\
806
753
  .times(1).and_return { assert(true) }
807
754
  @storage.fulltext_index_delete('index', 4, 'target_id')
808
755
  end
@@ -828,7 +775,7 @@ DELETE FROM index WHERE origin_id = ? AND c1 = ? AND c2 = ?
828
775
  end
829
776
  def test_delete_index_element__origin
830
777
  handle = flexmock('DB-Handle')
831
- @dbi.should_receive(:do).with(<<-SQL, 15).times(1).and_return {
778
+ @dbi.should_receive(:do).once.with(<<-SQL, 15).times(1).and_return {
832
779
  DELETE FROM index WHERE origin_id = ?
833
780
  SQL
834
781
  assert(true)
@@ -837,7 +784,7 @@ DELETE FROM index WHERE origin_id = ? AND c1 = ? AND c2 = ?
837
784
  end
838
785
  def test_delete_index_element__target
839
786
  handle = flexmock('DB-Handle')
840
- @dbi.should_receive(:do).with(<<-SQL, 15).times(1).and_return {
787
+ @dbi.should_receive(:do).once.with(<<-SQL, 15).times(1).and_return {
841
788
  DELETE FROM index WHERE target_id = ?
842
789
  SQL
843
790
  assert(true)
@@ -5,10 +5,11 @@
5
5
  $: << File.expand_path('../lib/', File.dirname(__FILE__))
6
6
  $: << File.dirname(__FILE__)
7
7
  require 'minitest/autorun'
8
+ require 'flexmock/test_unit'
9
+ require 'flexmock'
8
10
  require 'odba/stub'
9
11
  require 'odba/persistable'
10
12
  require 'odba/odba'
11
- require 'flexmock'
12
13
  require 'yaml'
13
14
 
14
15
  module ODBA
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: odba
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaomi Hatakeyama, Zeno R.R. Davatz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-23 00:00:00.000000000 Z
11
+ date: 2018-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ydbi
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.5.1
19
+ version: 0.5.6
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.5.1
26
+ version: 0.5.6
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ydbd-pg
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.5.1
33
+ version: 0.5.6
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.5.1
40
+ version: 0.5.6
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: flexmock
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +94,48 @@ dependencies:
80
94
  - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: test-unit
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: debug_inspector
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
83
139
  - !ruby/object:Gem::Dependency
84
140
  name: simplecov
85
141
  requirement: !ruby/object:Gem::Requirement
@@ -165,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
221
  version: '0'
166
222
  requirements: []
167
223
  rubyforge_project:
168
- rubygems_version: 2.5.1
224
+ rubygems_version: 2.7.3
169
225
  signing_key:
170
226
  specification_version: 4
171
227
  summary: Ruby Software for ODDB.org Memory Management