postspec 0.2.1 → 0.2.3

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
2
  SHA256:
3
- metadata.gz: b88f22ce1cf917e68dd66cc1e084e8e7b17ebcce32013ec55c630257449fb340
4
- data.tar.gz: 40eb91843fbcadb5cf9c09422df74b407589f92b63b1b68111538bad28e36f6e
3
+ metadata.gz: ac68d61de369fe3aced2e4b6a2dfebc1e9d293c879854f3e094755357bde7a63
4
+ data.tar.gz: d0bb3d0e90935bd47d080aee31572a3a04b91937de6d4879ce2e3150754d3a0c
5
5
  SHA512:
6
- metadata.gz: 2f3ecf2cac38acf9d958e9b2adf114a8ba8b31b8ad4779a6cc423403ad19cf50672ac9e1dffd2efeabb931a8f0599884c5233ce28c406095bcd25ae271d48908
7
- data.tar.gz: fb22f7b632084732c5cfbfd3522da455fecf07da27536611cf09a4a8e773b04979fdfa418167f4904b142eb7ea179adc87a1ffa62bc3477cf327edac7226ae80
6
+ metadata.gz: f42c180b14d7574c8f85223a1b50d7169b05a2a459cf44ba739e7d1cea4f320d17b983800e20acb995ea6dd21220490f97e36e732bba72371689e964c0b8e067
7
+ data.tar.gz: 21226245ef6d07cd076585b550ac2f5d820d82372430415934b63ad97f83a7f010e45243190b6172bc75831dd5c8b2ed836ed15feaec96a7e9230bb9a71249cc
@@ -21,16 +21,20 @@ module Postspec
21
21
  conn.map "select table_uid, record_id from postspec.seeds"
22
22
  end
23
23
 
24
+ # Returns an array from table name to maximum ID used in the table or in
25
+ # the root table if this is a subtable
24
26
  def table_max_ids
25
27
  result = table_sequence_ids(all: true)
26
- postspec.type.tables.select(&:subtable?).each { |table|
27
- result[table.uid] = result[table.supertable.uid] or raise "Oops"
28
+ postspec.type.tables.select(&:sub_table?).each { |table|
29
+ result[table.uid] = result[table.root_table.uid] or raise "Oops: #{table.uid}"
28
30
  }
29
31
  result
30
32
  end
31
33
 
32
34
  # Returns map from table UID to record ID of the last record to be kept so
33
- # that 'delete from table_uid where id > record_id' does the right thing.
35
+ # that 'delete from table_uid where id is null or id > record_id' does the right thing
36
+ #
37
+ #
34
38
  # Note: This assumes that the change triggers has been installed beforehand
35
39
  def dirty_tables
36
40
  seed_ids = table_seed_ids
@@ -59,6 +63,7 @@ module Postspec
59
63
  # puts "Environment#clean"
60
64
  @uids = {}
61
65
  user_tables = dirty_tables
66
+
62
67
  postspec_tables = CHANGE_TABLE_UIDS
63
68
  sql = render.delete_tables(user_tables) +
64
69
  render.delete_tables(postspec_tables)
@@ -104,7 +104,7 @@ module Postspec
104
104
  sql =
105
105
  uids.map { |uid, id| "delete from #{uid}" + (id > 0 ? " where id > #{id}" : "") } +
106
106
  uids.select { |uid|
107
- uid =~ /^postspec\./ ? true : !postspec.type.dot(uid).subtable?
107
+ uid =~ /^postspec\./ ? true : !postspec.type.dot(uid).sub_table?
108
108
  }.map { |uid, id|
109
109
  "alter table #{uid} alter column id restart" + (id > 0 ? " with #{id+1}" : "")
110
110
  }
@@ -1,3 +1,3 @@
1
1
  module Postspec
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-29 00:00:00.000000000 Z
11
+ date: 2023-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-inflector