postspec 0.2.1 → 0.2.2

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: b7a02e5c14b838e05beeedf3ddd025b33b504ce0846d087680a2eb9dda993a97
4
+ data.tar.gz: 1870c61f2595c33c6ea2453cdf1f56fea06fb3433ca390eb78e79f090a0a84d5
5
5
  SHA512:
6
- metadata.gz: 2f3ecf2cac38acf9d958e9b2adf114a8ba8b31b8ad4779a6cc423403ad19cf50672ac9e1dffd2efeabb931a8f0599884c5233ce28c406095bcd25ae271d48908
7
- data.tar.gz: fb22f7b632084732c5cfbfd3522da455fecf07da27536611cf09a4a8e773b04979fdfa418167f4904b142eb7ea179adc87a1ffa62bc3477cf327edac7226ae80
6
+ metadata.gz: 0a4a823ba661cc886208c72a7e92486ad8b836c5502acbd6bc0fe8a477f201490f5a1fb3433644e4ec296089b2d35d55d4fc35dfbe46ce4029f779924c2b603d
7
+ data.tar.gz: ae0b0c54259a9ddcdd29bda1a7cc6eba57aa2810eb6d0b23146d15afc05afeaf3306fda0d07e8db8fa5b84d93d702f0af40403f32071f4601def861fd6f56c12
@@ -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,9 @@ module Postspec
59
63
  # puts "Environment#clean"
60
64
  @uids = {}
61
65
  user_tables = dirty_tables
66
+ $stderr.puts "user_table: #{user_tables.inspect}"
67
+ $stderr.puts " #{user_tables.select { |k,v| v.nil? }.inspect}"
68
+
62
69
  postspec_tables = CHANGE_TABLE_UIDS
63
70
  sql = render.delete_tables(user_tables) +
64
71
  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.2"
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.2
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-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-inflector