postspec 0.2.0 → 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: 48d097d94a17f8bbd0ba22d2457ab573350d26f5ef21bea45505eb358429aed9
4
- data.tar.gz: e2134998511ecffe63d80f021125a043da6ec02a0075764a59dc0dd3b3940b7f
3
+ metadata.gz: b7a02e5c14b838e05beeedf3ddd025b33b504ce0846d087680a2eb9dda993a97
4
+ data.tar.gz: 1870c61f2595c33c6ea2453cdf1f56fea06fb3433ca390eb78e79f090a0a84d5
5
5
  SHA512:
6
- metadata.gz: 3955b4de636c7f56471ce6250225d8fa9dec49436d393d8fe323a7d9b357406c33d1aa141d5623739dcb65ed4f9aaae48e71a31f6fe4e457db4ac85291c3cd8c
7
- data.tar.gz: 3228b4175065e0a1553cb9d984cab7470a5ae089a84f39f803c0e9d1f3fc7ad20c7fc6d22eed0beb3b945b8f7c15d194a1ef6aa545a2e47b1447abb6485665a3
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)
@@ -42,7 +42,7 @@ module Postspec
42
42
  constrain search_path, [String], NilClass
43
43
  constrain push_sql, String, [String], NilClass
44
44
  constrain pop_sql, String, [String], NilClass
45
- constrain ids, String => Integer
45
+ constrain ids, { String => Integer }
46
46
  constrain fox_anchors, FixtureFox::Anchors, NilClass
47
47
  @postspec = postspec
48
48
  @parent = parent
@@ -129,7 +129,7 @@ module Postspec
129
129
  def transaction?() false end
130
130
 
131
131
  def initialize(postspec, ids, anchors = nil)
132
- constrain ids, String => Integer
132
+ constrain ids, { String => Integer }
133
133
  constrain anchors, FixtureFox::Anchors, NilClass
134
134
  super(postspec, nil, nil, [], [], ids, anchors)
135
135
  end
@@ -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.0"
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.0
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: 2022-07-20 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