sequel_bitemporal 0.8.9 → 0.9.0

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: 68ac021c3521e98f78d3f9bc44c21267cc07c60a
4
- data.tar.gz: fa89baf10e99cbed3ed83b2072a1c2e5b2a73ca8
2
+ SHA256:
3
+ metadata.gz: 4f44bf401ad71c80c9815ff7d2e3508edf8e5bdbef4112b36bf86d06a6d02523
4
+ data.tar.gz: 19b320461ebbdac3b2e7ace0117ffa2921180dd602b59e5145d2c1771987d993
5
5
  SHA512:
6
- metadata.gz: 18a5b6e13d4c74e905262dd6844db54b5550f8f626bfad46aff2093d82bc06217294f1cef60ca25361d6fd6604c48a1fdfb29531ea448a6de9f802075e6cfa1c
7
- data.tar.gz: 132614240d0c4244938b136a7b5be58bd741368cd616c6fcd9335f4c4fc3156bd79fe1df1c4e4392a11988ca117ff690c5cde95c8e3e30fb7bb7f9ac46a97cbe
6
+ metadata.gz: 1e9928807145999a4ba2215b10e3169bb26e63bc42137c28b9fc05ad6ac9a2e66f10c69ccdda40ae1ae8d7bbfabad0f1f921122fc3e0bb155da559b335ffa97f
7
+ data.tar.gz: a7fac94af384e4478fd9d6f98a6381bf03278e1310d8d97dff5bea449f2e3c5baeb962e3552774535a14b0a021a5b0ce22d76b659b08f7fcf9fe9a17a36d31dc
@@ -3,13 +3,22 @@ cache:
3
3
  bundler: true
4
4
  sudo: false
5
5
  rvm:
6
- - 1.9.3
7
- - 2.0
8
- - 2.1
9
- - 2.2
10
- - jruby-19mode
6
+ - 2.2.7
7
+ - 2.3.4
8
+ - 2.4.2
9
+ - jruby-9.1.13.0
10
+ before_script:
11
+ - psql -c 'create database sequel_bitemporal_test;' -U postgres
11
12
  env:
12
- - SQLITE=1
13
- - PG=1
14
- addons:
15
- postgresql: 9.2
13
+ - SQLITE=1 SEQUEL='~> 4.0'
14
+ - SQLITE=1 SEQUEL='~> 5.0'
15
+ - PG=1 SEQUEL='~> 4.0'
16
+ - PG=1 SEQUEL='~> 5.0'
17
+ gemfile:
18
+ - ci/sequel.gemfile
19
+ matrix:
20
+ allow_failures:
21
+ - rvm: jruby-9.1.13.0
22
+ env: PG=1 SEQUEL='~> 4.0'
23
+ - rvm: jruby-9.1.13.0
24
+ env: PG=1 SEQUEL='~> 5.0'
data/Gemfile CHANGED
@@ -1,8 +1,6 @@
1
1
  source "http://rubygems.org"
2
2
  gemspec
3
3
 
4
- gem "pry"
5
-
6
4
  platforms :ruby do
7
5
  gem "pg"
8
6
  gem "sqlite3"
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :path => '../'
4
+
5
+ gem 'sequel', "#{ENV['SEQUEL']}"
6
+
7
+ # MRI/Rubinius Adapter Dependencies
8
+ platforms :ruby do
9
+ gem "pg"
10
+ gem "sqlite3"
11
+ end
12
+
13
+ # JRuby Adapter Dependencies
14
+ platforms :jruby do
15
+ gem "jdbc-postgres"
16
+ gem "jdbc-sqlite3"
17
+ end
@@ -46,12 +46,25 @@ module Sequel
46
46
  missing = bitemporal_version_columns - version.columns
47
47
  raise Error, "bitemporal plugin requires the following missing column#{"s" if missing.size>1} on version class: #{missing.join(", ")}" unless missing.empty?
48
48
 
49
- if Sequel::Plugins::Bitemporal.pg_jdbc?(master.db)
50
- master.plugin :pg_typecast_on_load, *master.columns
51
- elsif Sequel::Plugins::Bitemporal.jdbc?(master.db)
49
+ if Sequel::Plugins::Bitemporal.jdbc?(master.db)
52
50
  master.plugin :typecast_on_load, *master.columns
53
51
  end
54
52
 
53
+ # Sequel::Model.def_dataset_method has been deprecated and moved to the
54
+ # def_dataset_method plugin in Sequel 4.46.0, it was not loaded by
55
+ # default from 5.0
56
+ begin
57
+ master.plugin :def_dataset_method
58
+ rescue LoadError
59
+ end
60
+ # Sequel::Model#set_all has been deprecated and moved to the whitelist
61
+ # security plugin in Sequel 4.46.0, it was not loaded by default from 5.0
62
+ begin
63
+ master.plugin :whitelist_security
64
+ version.plugin :whitelist_security
65
+ rescue LoadError
66
+ end
67
+
55
68
  master.instance_eval do
56
69
  @version_class = version
57
70
  base_alias = opts.fetch :base_alias do
@@ -153,14 +166,12 @@ module Sequel
153
166
  end
154
167
  master.def_dataset_method :with_current_or_future_versions do
155
168
  eager_graph(:current_or_future_versions).where(
156
- Sequel.negate(current_or_future_versions__id: nil)
169
+ Sequel.negate(Sequel.qualify(:current_or_future_versions, :id) => nil)
157
170
  )
158
171
  end
159
172
  version.many_to_one :master, class: master, key: :master_id
160
173
  version.class_eval do
161
- if Sequel::Plugins::Bitemporal.pg_jdbc?(master.db)
162
- plugin :pg_typecast_on_load, *columns
163
- elsif Sequel::Plugins::Bitemporal.jdbc?(master.db)
174
+ if Sequel::Plugins::Bitemporal.jdbc?(master.db)
164
175
  plugin :typecast_on_load, *columns
165
176
  end
166
177
 
@@ -355,7 +366,11 @@ module Sequel
355
366
 
356
367
  def destroy
357
368
  point_in_time = ::Sequel::Plugins::Bitemporal.point_in_time
358
- versions_dataset.where(expired_at: nil).where("valid_to>valid_from").update expired_at: point_in_time
369
+ versions_dataset.where(
370
+ expired_at: nil
371
+ ).where(
372
+ Sequel.lit("valid_to>valid_from")
373
+ ).update expired_at: point_in_time
359
374
  end
360
375
 
361
376
  def destroy_version(version, expand_previous_version)
@@ -370,7 +385,7 @@ module Sequel
370
385
  previous = versions_dataset.where({
371
386
  expired_at: nil,
372
387
  valid_to: version.valid_from,
373
- }).where("valid_to>valid_from").first
388
+ }).where(Sequel.lit("valid_to>valid_from")).first
374
389
  if previous
375
390
  if version_was_valid
376
391
  success &&= save_fossil previous, created_at: point_in_time, valid_from: now, valid_to: version.valid_to
@@ -471,11 +486,11 @@ module Sequel
471
486
  lock!
472
487
  set master_changes
473
488
  expired = versions_dataset.where expired_at: nil
474
- expired = expired.exclude "valid_from=valid_to"
475
- expired = expired.exclude "valid_to<=?", pending_version.valid_from
476
- pending_version.valid_to ||= expired.where("valid_from>?", pending_version.valid_from).min(:valid_from)
489
+ expired = expired.exclude Sequel.lit("valid_from=valid_to")
490
+ expired = expired.exclude Sequel.lit("valid_to<=?", pending_version.valid_from)
491
+ pending_version.valid_to ||= expired.where(Sequel.lit("valid_from>?", pending_version.valid_from)).min(:valid_from)
477
492
  pending_version.valid_to ||= Time.utc 9999
478
- expired = expired.exclude "valid_from>=?", pending_version.valid_to
493
+ expired = expired.exclude Sequel.lit("valid_from>=?", pending_version.valid_to)
479
494
  expired = expired.all
480
495
  expired.each do |expired_version|
481
496
  if expired_version.valid_from<pending_version.valid_from && expired_version.valid_to>pending_version.valid_from
@@ -492,9 +507,9 @@ module Sequel
492
507
  @propagated_during_last_save = []
493
508
  lock!
494
509
  futures = versions_dataset.where expired_at: nil
495
- futures = futures.exclude "valid_from=valid_to"
496
- futures = futures.exclude "valid_to<=?", pending_version.valid_from
497
- futures = futures.where "valid_from>?", pending_version.valid_from
510
+ futures = futures.exclude Sequel.lit("valid_from=valid_to")
511
+ futures = futures.exclude Sequel.lit("valid_to<=?", pending_version.valid_from)
512
+ futures = futures.where Sequel.lit("valid_from>?", pending_version.valid_from)
498
513
  futures = futures.order(:valid_from).all
499
514
 
500
515
  to_check_columns = self.class.version_class.columns - excluded_columns
@@ -10,10 +10,6 @@ module Sequel
10
10
  def self.jdbc?(db)
11
11
  db.adapter_scheme==:jdbc
12
12
  end
13
-
14
- def self.pg_jdbc?(db)
15
- db.database_type==:postgres && jdbc?(db)
16
- end
17
13
  end
18
14
  end
19
15
  end
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "sequel_bitemporal"
6
- s.version = "0.8.9"
6
+ s.version = "0.9.0"
7
7
  s.authors = ["Joseph HALTER", "Jonathan TRON"]
8
8
  s.email = ["joseph.halter@thetalentbox.com", "jonathan.tron@thetalentbox.com"]
9
9
  s.homepage = "https://github.com/TalentBox/sequel_bitemporal"
@@ -16,9 +16,9 @@ Gem::Specification.new do |s|
16
16
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
17
  s.require_paths = ["lib"]
18
18
 
19
- s.add_runtime_dependency "sequel", ">= 3.41", "< 5.0"
19
+ s.add_runtime_dependency "sequel", ">= 4.0", "< 6.0"
20
20
 
21
- s.add_development_dependency "rspec", "~> 3.2.0"
21
+ s.add_development_dependency "rspec", "~> 3.6.0"
22
22
  s.add_development_dependency "timecop"
23
23
  s.add_development_dependency "rake"
24
24
  end
@@ -382,10 +382,10 @@ describe "Sequel::Plugins::Bitemporal" do
382
382
  master = @master_class.new
383
383
  master.update_attributes name: "Single Standard", price: 98
384
384
  master.update_attributes name: "Single Standard", price: 94, valid_from: Date.today+2
385
- expect(@master_class.eager_graph(:current_version).where("rooms_current_version.id IS NOT NULL").first).to be
385
+ expect(@master_class.eager_graph(:current_version).where(Sequel.lit("rooms_current_version.id IS NOT NULL")).first).to be
386
386
  Timecop.freeze Date.today+1
387
387
  master.destroy
388
- expect(@master_class.eager_graph(:current_version).where("rooms_current_version.id IS NOT NULL").first).to be_nil
388
+ expect(@master_class.eager_graph(:current_version).where(Sequel.lit("rooms_current_version.id IS NOT NULL")).first).to be_nil
389
389
  end
390
390
  it "allows eager loading via a separate query" do
391
391
  master = @master_class.new
@@ -468,25 +468,25 @@ describe "Sequel::Plugins::Bitemporal" do
468
468
  }
469
469
  expect(master.current_version.price).to eq(94)
470
470
  Sequel::Plugins::Bitemporal.at(Date.today-1) do
471
- expect(master.current_version(true).price).to eq(98)
471
+ expect(master.current_version(:reload => true).price).to eq(98)
472
472
  end
473
473
  Sequel::Plugins::Bitemporal.at(Date.today+1) do
474
- expect(master.current_version(true).price).to eq(93)
474
+ expect(master.current_version(:reload => true).price).to eq(93)
475
475
  end
476
476
  Sequel::Plugins::Bitemporal.at(Date.today+2) do
477
- expect(master.current_version(true).price).to eq(96)
477
+ expect(master.current_version(:reload => true).price).to eq(96)
478
478
  end
479
479
  Sequel::Plugins::Bitemporal.as_we_knew_it(Date.today-1) do
480
- expect(master.current_version(true).price).to eq(95)
480
+ expect(master.current_version(:reload => true).price).to eq(95)
481
481
  expect(master.current_version).to be_current
482
482
  Sequel::Plugins::Bitemporal.at(Date.today-1) do
483
- expect(master.current_version(true).price).to eq(98)
483
+ expect(master.current_version(:reload => true).price).to eq(98)
484
484
  end
485
485
  Sequel::Plugins::Bitemporal.at(Date.today+1) do
486
- expect(master.current_version(true).price).to eq(93)
486
+ expect(master.current_version(:reload => true).price).to eq(93)
487
487
  end
488
488
  Sequel::Plugins::Bitemporal.at(Date.today+2) do
489
- expect(master.current_version(true).price).to eq(91)
489
+ expect(master.current_version(:reload => true).price).to eq(91)
490
490
  end
491
491
  end
492
492
  end
@@ -511,17 +511,17 @@ describe "Sequel::Plugins::Bitemporal" do
511
511
  Timecop.freeze Date.today+1
512
512
  master.update_attributes name: "Single Standard", price: 99
513
513
  master.update_attributes name: "Single Standard", price: 94, valid_from: Date.today+2
514
- res = @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(current_or_future_versions__id: nil) & {price: 99}).all.first
514
+ res = @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(Sequel.qualify(:current_or_future_versions, :id) => nil) & {price: 99}).all.first
515
515
  expect(res).to be
516
516
  expect(res.current_or_future_versions.size).to eq(1)
517
517
  expect(res.current_or_future_versions.first.price).to eq(99)
518
- res = @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(current_or_future_versions__id: nil) & {price: 94}).all.first
518
+ res = @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(Sequel.qualify(:current_or_future_versions, :id) => nil) & {price: 94}).all.first
519
519
  expect(res).to be
520
520
  expect(res.current_or_future_versions.size).to eq(1)
521
521
  expect(res.current_or_future_versions.first.price).to eq(94)
522
522
  Timecop.freeze Date.today+1
523
523
  master.destroy
524
- expect(@master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(current_or_future_versions__id: nil)).all).to be_empty
524
+ expect(@master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(Sequel.qualify(:current_or_future_versions, :id) => nil)).all).to be_empty
525
525
  end
526
526
  it "association current or future versions ignores versions with valid_from==valid_to" do
527
527
  master = @master_class.new
@@ -613,7 +613,7 @@ describe "Sequel::Plugins::Bitemporal" do
613
613
  plugin :bitemporal, version_class: MyNameVersion
614
614
  end
615
615
  expect do
616
- MyName.eager_graph(:current_version).where("my_name_current_version.id IS NOT NULL").first
616
+ MyName.eager_graph(:current_version).where(Sequel.lit("my_name_current_version.id IS NOT NULL")).first
617
617
  end.not_to raise_error
618
618
  Object.send :remove_const, :MyName
619
619
  Object.send :remove_const, :MyNameVersion
@@ -653,7 +653,7 @@ describe "Sequel::Plugins::Bitemporal" do
653
653
  | King Size | 98 | 2009-11-29 | | 2009-11-28 | MAX DATE | |
654
654
  }
655
655
  Sequel::Plugins::Bitemporal.as_we_knew_it(Date.today+2) do
656
- master.current_version(true).destroy
656
+ master.current_version(:reload => true).destroy
657
657
  end
658
658
  expect(master).to have_versions %Q{
659
659
  | name | price | created_at | expired_at | valid_from | valid_to | current |
@@ -937,7 +937,7 @@ describe "Sequel::Plugins::Bitemporal", "with audit, specifying how to get the a
937
937
  expect do
938
938
  redefined_base_alias.eager_graph(
939
939
  :current_version
940
- ).where("anything_current_version.id IS NOT NULL").first
940
+ ).where(Sequel.lit("anything_current_version.id IS NOT NULL")).first
941
941
  end.not_to raise_error
942
942
  end
943
943
  end
@@ -373,10 +373,10 @@ if DbHelpers.pg?
373
373
  master = @master_class.new
374
374
  master.update_attributes name: "Single Standard", price: 98
375
375
  master.update_attributes name: "Single Standard", price: 94, valid_from: Date.today+2
376
- expect(@master_class.eager_graph(:current_version).where("rooms_current_version.id IS NOT NULL").first).to be
376
+ expect(@master_class.eager_graph(:current_version).where(Sequel.lit("rooms_current_version.id IS NOT NULL")).first).to be
377
377
  Timecop.freeze Date.today+1
378
378
  master.destroy
379
- expect(@master_class.eager_graph(:current_version).where("rooms_current_version.id IS NOT NULL").first).to be_nil
379
+ expect(@master_class.eager_graph(:current_version).where(Sequel.lit("rooms_current_version.id IS NOT NULL")).first).to be_nil
380
380
  end
381
381
  it "allows loading masters with a current version" do
382
382
  master_destroyed = @master_class.new
@@ -428,25 +428,25 @@ if DbHelpers.pg?
428
428
  }
429
429
  expect(master.current_version.price).to eq(94)
430
430
  Sequel::Plugins::Bitemporal.at(Date.today-1) do
431
- expect(master.current_version(true).price).to eq(98)
431
+ expect(master.current_version(:reload => true).price).to eq(98)
432
432
  end
433
433
  Sequel::Plugins::Bitemporal.at(Date.today+1) do
434
- expect(master.current_version(true).price).to eq(93)
434
+ expect(master.current_version(:reload => true).price).to eq(93)
435
435
  end
436
436
  Sequel::Plugins::Bitemporal.at(Date.today+2) do
437
- expect(master.current_version(true).price).to eq(96)
437
+ expect(master.current_version(:reload => true).price).to eq(96)
438
438
  end
439
439
  Sequel::Plugins::Bitemporal.as_we_knew_it(Date.today-1) do
440
- expect(master.current_version(true).price).to eq(95)
440
+ expect(master.current_version(:reload => true).price).to eq(95)
441
441
  expect(master.current_version).to be_current
442
442
  Sequel::Plugins::Bitemporal.at(Date.today-1) do
443
- expect(master.current_version(true).price).to eq(98)
443
+ expect(master.current_version(:reload => true).price).to eq(98)
444
444
  end
445
445
  Sequel::Plugins::Bitemporal.at(Date.today+1) do
446
- expect(master.current_version(true).price).to eq(93)
446
+ expect(master.current_version(:reload => true).price).to eq(93)
447
447
  end
448
448
  Sequel::Plugins::Bitemporal.at(Date.today+2) do
449
- expect(master.current_version(true).price).to eq(91)
449
+ expect(master.current_version(:reload => true).price).to eq(91)
450
450
  end
451
451
  end
452
452
  end
@@ -471,17 +471,17 @@ if DbHelpers.pg?
471
471
  Timecop.freeze Date.today+1
472
472
  master.update_attributes name: "Single Standard", price: 99
473
473
  master.update_attributes name: "Single Standard", price: 94, valid_from: Date.today+2
474
- res = @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(current_or_future_versions__id: nil) & {price: 99}).all.first
474
+ res = @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(Sequel.qualify(:current_or_future_versions, :id) => nil) & {price: 99}).all.first
475
475
  expect(res).to be
476
476
  expect(res.current_or_future_versions.size).to eq(1)
477
477
  expect(res.current_or_future_versions.first.price).to eq(99)
478
- res = @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(current_or_future_versions__id: nil) & {price: 94}).all.first
478
+ res = @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(Sequel.qualify(:current_or_future_versions, :id) => nil) & {price: 94}).all.first
479
479
  expect(res).to be
480
480
  expect(res.current_or_future_versions.size).to eq(1)
481
481
  expect(res.current_or_future_versions.first.price).to eq(94)
482
482
  Timecop.freeze Date.today+1
483
483
  master.destroy
484
- expect(@master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(current_or_future_versions__id: nil)).all).to be_empty
484
+ expect(@master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(Sequel.qualify(:current_or_future_versions, :id) => nil)).all).to be_empty
485
485
  end
486
486
  it "allows loading masters with current or future versions" do
487
487
  master_destroyed = @master_class.new
@@ -519,7 +519,7 @@ if DbHelpers.pg?
519
519
  plugin :bitemporal, version_class: MyNameVersion
520
520
  end
521
521
  expect do
522
- MyName.eager_graph(:current_version).where("my_name_current_version.id IS NOT NULL").first
522
+ MyName.eager_graph(:current_version).where(Sequel.lit("my_name_current_version.id IS NOT NULL")).first
523
523
  end.not_to raise_error
524
524
  Object.send :remove_const, :MyName
525
525
  Object.send :remove_const, :MyNameVersion
@@ -559,7 +559,7 @@ if DbHelpers.pg?
559
559
  | King Size | 98 | 2009-11-29 | | 2009-11-28 | MAX DATE | |
560
560
  }
561
561
  Sequel::Plugins::Bitemporal.as_we_knew_it(Date.today+2) do
562
- master.current_version(true).destroy
562
+ master.current_version(:reload => true).destroy
563
563
  end
564
564
  expect(master).to have_versions %Q{
565
565
  | name | price | created_at | expired_at | valid_from | valid_to | current |
@@ -292,10 +292,10 @@ describe "Sequel::Plugins::Bitemporal" do
292
292
  master = @master_class.new
293
293
  master.update_attributes name: "Single Standard", price: 98
294
294
  master.update_attributes name: "Single Standard", price: 94, valid_from: Time.now+2*hour
295
- expect(@master_class.eager_graph(:current_version).where("rooms_current_version.id IS NOT NULL").first).to be
295
+ expect(@master_class.eager_graph(:current_version).where(Sequel.lit("rooms_current_version.id IS NOT NULL")).first).to be
296
296
  Timecop.freeze Time.now+hour
297
297
  master.destroy
298
- expect(@master_class.eager_graph(:current_version).where("rooms_current_version.id IS NOT NULL").first).to be_nil
298
+ expect(@master_class.eager_graph(:current_version).where(Sequel.lit("rooms_current_version.id IS NOT NULL")).first).to be_nil
299
299
  end
300
300
  it "allows loading masters with a current version" do
301
301
  master_destroyed = @master_class.new
@@ -334,7 +334,7 @@ describe "Sequel::Plugins::Bitemporal" do
334
334
  master.update_attributes price: 94
335
335
  expect(master.current_version.price).to eq(94)
336
336
  Sequel::Plugins::Bitemporal.as_we_knew_it(Time.now-1*hour) do
337
- expect(master.current_version(true).price).to eq(98)
337
+ expect(master.current_version(:reload => true).price).to eq(98)
338
338
  end
339
339
  end
340
340
  it "correctly reset time if failure when going back in time" do
@@ -358,17 +358,17 @@ describe "Sequel::Plugins::Bitemporal" do
358
358
  Timecop.freeze Time.now+1*hour
359
359
  master.update_attributes name: "Single Standard", price: 99
360
360
  master.update_attributes name: "Single Standard", price: 94, valid_from: Time.now+2*hour
361
- res = @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(current_or_future_versions__id: nil) & {price: 99}).all.first
361
+ res = @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(Sequel.qualify(:current_or_future_versions, :id) => nil) & {price: 99}).all.first
362
362
  expect(res).to be
363
363
  expect(res.current_or_future_versions.size).to eq(1)
364
364
  expect(res.current_or_future_versions.first.price).to eq(99)
365
- res = @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(current_or_future_versions__id: nil) & {price: 94}).all.first
365
+ res = @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(Sequel.qualify(:current_or_future_versions, :id) => nil) & {price: 94}).all.first
366
366
  expect(res).to be
367
367
  expect(res.current_or_future_versions.size).to eq(1)
368
368
  expect(res.current_or_future_versions.first.price).to eq(94)
369
369
  Timecop.freeze Time.now+1*hour
370
370
  master.destroy
371
- expect(@master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(current_or_future_versions__id: nil)).all).to be_empty
371
+ expect(@master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(Sequel.qualify(:current_or_future_versions, :id) => nil)).all).to be_empty
372
372
  end
373
373
  it "allows loading masters with current or future versions" do
374
374
  master_destroyed = @master_class.new
@@ -292,10 +292,10 @@ if DbHelpers.pg?
292
292
  master = @master_class.new
293
293
  master.update_attributes name: "Single Standard", price: 98
294
294
  master.update_attributes name: "Single Standard", price: 94, valid_from: Time.now+2*hour
295
- expect(@master_class.eager_graph(:current_version).where("rooms_current_version.id IS NOT NULL").first).to be
295
+ expect(@master_class.eager_graph(:current_version).where(Sequel.lit("rooms_current_version.id IS NOT NULL")).first).to be
296
296
  Timecop.freeze Time.now+hour
297
297
  master.destroy
298
- expect(@master_class.eager_graph(:current_version).where("rooms_current_version.id IS NOT NULL").first).to be_nil
298
+ expect(@master_class.eager_graph(:current_version).where(Sequel.lit("rooms_current_version.id IS NOT NULL")).first).to be_nil
299
299
  end
300
300
  it "allows loading masters with a current version" do
301
301
  master_destroyed = @master_class.new
@@ -334,7 +334,7 @@ if DbHelpers.pg?
334
334
  master.update_attributes price: 94
335
335
  expect(master.current_version.price).to eq(94)
336
336
  Sequel::Plugins::Bitemporal.as_we_knew_it(Time.now-1*hour) do
337
- expect(master.current_version(true).price).to eq(98)
337
+ expect(master.current_version(:reload => true).price).to eq(98)
338
338
  end
339
339
  end
340
340
  it "correctly reset time if failure when going back in time" do
@@ -358,17 +358,17 @@ if DbHelpers.pg?
358
358
  Timecop.freeze Time.now+1*hour
359
359
  master.update_attributes name: "Single Standard", price: 99
360
360
  master.update_attributes name: "Single Standard", price: 94, valid_from: Time.now+2*hour
361
- res = @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(current_or_future_versions__id: nil) & {price: 99}).all.first
361
+ res = @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(Sequel.qualify(:current_or_future_versions, :id) => nil) & {price: 99}).all.first
362
362
  expect(res).to be
363
363
  expect(res.current_or_future_versions.size).to eq(1)
364
364
  expect(res.current_or_future_versions.first.price).to eq(99)
365
- res = @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(current_or_future_versions__id: nil) & {price: 94}).all.first
365
+ res = @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(Sequel.qualify(:current_or_future_versions, :id) => nil) & {price: 94}).all.first
366
366
  expect(res).to be
367
367
  expect(res.current_or_future_versions.size).to eq(1)
368
368
  expect(res.current_or_future_versions.first.price).to eq(94)
369
369
  Timecop.freeze Time.now+1*hour
370
370
  master.destroy
371
- expect(@master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(current_or_future_versions__id: nil)).all).to be_empty
371
+ expect(@master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(Sequel.qualify(:current_or_future_versions, :id) => nil)).all).to be_empty
372
372
  end
373
373
  it "allows loading masters with current or future versions" do
374
374
  master_destroyed = @master_class.new
@@ -1,11 +1,11 @@
1
1
  require "sequel"
2
2
  require "timecop"
3
- require "pry"
4
3
 
5
4
  Dir[File.expand_path("../support/*.rb", __FILE__)].each{|f| require f}
6
5
  ENV["TZ"]="UTC"
7
6
 
8
7
  require "sequel_bitemporal"
8
+ Sequel::Deprecation.output = false
9
9
 
10
10
  rspec_exclusions = {}
11
11
 
@@ -46,6 +46,21 @@ module DbHelpers
46
46
  set_dataset :rooms
47
47
  plugin :bitemporal, bitemporal_options
48
48
  end
49
+
50
+ DB.drop_table(:my_name_versions) if DB.table_exists?(:my_name_versions)
51
+ DB.drop_table(:my_names) if DB.table_exists?(:my_names)
52
+
53
+ DB.create_table! :my_names do
54
+ primary_key :id
55
+ end
56
+ DB.create_table! :my_name_versions do
57
+ primary_key :id
58
+ foreign_key :master_id, :my_names
59
+ send(use_time ? :Time : :Date, :created_at)
60
+ send(use_time ? :Time : :Date, :expired_at)
61
+ send(use_time ? :Time : :Date, :valid_from)
62
+ send(use_time ? :Time : :Date, :valid_to)
63
+ end
49
64
  end
50
65
 
51
66
  def db_truncate
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_bitemporal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.9
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph HALTER
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-02-13 00:00:00.000000000 Z
12
+ date: 2018-11-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sequel
@@ -17,34 +17,34 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '3.41'
20
+ version: '4.0'
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
- version: '5.0'
23
+ version: '6.0'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
- version: '3.41'
30
+ version: '4.0'
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: '5.0'
33
+ version: '6.0'
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rspec
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 3.2.0
40
+ version: 3.6.0
41
41
  type: :development
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 3.2.0
47
+ version: 3.6.0
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: timecop
50
50
  requirement: !ruby/object:Gem::Requirement
@@ -89,6 +89,7 @@ files:
89
89
  - LICENSE
90
90
  - README.md
91
91
  - Rakefile
92
+ - ci/sequel.gemfile
92
93
  - lib/sequel/plugins/bitemporal.rb
93
94
  - lib/sequel_bitemporal.rb
94
95
  - sequel_bitemporal.gemspec
@@ -120,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
121
  version: '0'
121
122
  requirements: []
122
123
  rubyforge_project:
123
- rubygems_version: 2.5.1
124
+ rubygems_version: 2.7.6
124
125
  signing_key:
125
126
  specification_version: 4
126
127
  summary: Bitemporal versioning for sequel.