waldit 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af8a3191d1b6471577a8f684b232d3634271624328674d04dc9db07556c1eca3
4
- data.tar.gz: dbb4b2d69139ae42581d57404d7c88bd95969deb9544fe006c3afe2a5870f8d1
3
+ metadata.gz: d97512d549606ea52367df080d5c7fe181f894595d804b31fe578ed5f1f26410
4
+ data.tar.gz: 9df7afe8818119e18391fd8b6284a2bf4ab40f87a75d0ca47979507e708395b8
5
5
  SHA512:
6
- metadata.gz: 03d6a7973c6ae02b6c7c0c859d8f02cb3135e0e0d7d0ad59c96247115f0e7db4c873928aebd3e1c0bbcb715f07c20ee7570cf3f02bbf66debf19a435cf511a7b
7
- data.tar.gz: 1296b36a4a737dfe4f4718dc9eed2010535851e74361818b8cbf999ead2d87290d8f3340503fa6ae1bf3904e59cc6253d531195eb87b0310976c07afa6f61840
6
+ metadata.gz: aa935a49d7f9356ce6f0dc924b3fbf1bd9ba5c06923d45b893c92fb3e15df373dc6ce83d729b644bc0c9e6bef31f69f0804cf36e1acf5967ea66945da8e3f475
7
+ data.tar.gz: d196dc919ab630fb49f40e0c556c196948332aab5b672d68115d6a0dfb04e8c7691ff1270bd1c742eebbef11465c6034edd20d4ef05e413ce73574a410f3c6a4
@@ -30,8 +30,8 @@ module Waldit
30
30
 
31
31
  def create_waldit_publication
32
32
  reversible do |dir|
33
- dir.up { execute "CREATE PUBLICATION waldit" }
34
- dir.down { execute "DROP PUBLICATION waldit" }
33
+ dir.up { execute "CREATE PUBLICATION waldit_publication" }
34
+ dir.down { execute "DROP PUBLICATION waldit_publication" }
35
35
  end
36
36
  end
37
37
 
@@ -39,10 +39,10 @@ module Waldit
39
39
  reversible do |dir|
40
40
  dir.up do
41
41
  execute "ALTER TABLE #{table} REPLICA IDENTITY FULL"
42
- execute "ALTER PUBLICATION waldit ADD TABLE #{table}"
42
+ execute "ALTER PUBLICATION waldit_publication ADD TABLE #{table}"
43
43
  end
44
44
  dir.down do
45
- execute "ALTER PUBLICATION waldit DROP TABLE #{table}"
45
+ execute "ALTER PUBLICATION waldit_publication DROP TABLE #{table}"
46
46
  execute "ALTER TABLE #{table} REPLICA IDENTITY DEFAULT"
47
47
  end
48
48
  end
@@ -51,12 +51,12 @@ module Waldit
51
51
  def remove_table_from_waldit(table)
52
52
  reversible do |dir|
53
53
  dir.up do
54
- execute "ALTER PUBLICATION waldit DROP TABLE #{table}"
54
+ execute "ALTER PUBLICATION waldit_publication DROP TABLE #{table}"
55
55
  execute "ALTER TABLE #{table} REPLICA IDENTITY DEFAULT"
56
56
  end
57
57
  dir.down do
58
58
  execute "ALTER TABLE #{table} REPLICA IDENTITY FULL"
59
- execute "ALTER PUBLICATION waldit ADD TABLE #{table}"
59
+ execute "ALTER PUBLICATION waldit_publication ADD TABLE #{table}"
60
60
  end
61
61
  end
62
62
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Waldit
4
- VERSION = "0.0.9"
4
+ VERSION = "0.0.11"
5
5
  end
@@ -13,18 +13,22 @@ module Waldit
13
13
 
14
14
  case event
15
15
  when InsertEvent
16
- @connection.exec_prepared("waldit_insert", audit + [event.new.to_json])
16
+ new_attributes = clean_attributes(event.table, event.new)
17
+ @connection.exec_prepared("waldit_insert", audit + [new_attributes.to_json])
17
18
 
18
19
  when UpdateEvent
19
20
  return if event.diff.without(ignored_columns(event.table)).empty?
20
- @connection.exec_prepared("waldit_update", audit + [event.old.to_json, event.new.to_json])
21
+ old_attributes = clean_attributes(event.table, event.old)
22
+ new_attributes = clean_attributes(event.table, event.new)
23
+
24
+ @connection.exec_prepared("waldit_update", audit + [old_attributes.to_json, new_attributes.to_json])
21
25
 
22
26
  when DeleteEvent
23
27
  case @connection.exec_prepared("waldit_delete_cleanup", [event.transaction_id, event.table, event.primary_key]).values
24
28
  in [["update", previous_old]]
25
29
  @connection.exec_prepared("waldit_delete", audit + [previous_old])
26
30
  in []
27
- @connection.exec_prepared("waldit_delete", audit + [event.old.to_json])
31
+ @connection.exec_prepared("waldit_delete", audit + [clean_attributes(event.table, event.old).to_json])
28
32
  else
29
33
  # Don't need to audit anything on this case
30
34
  end
@@ -111,6 +115,10 @@ module Waldit
111
115
  Waldit.ignored_columns.call(table)
112
116
  end
113
117
 
118
+ def clean_attributes(table, attributes)
119
+ attributes.without(ignored_columns(table))
120
+ end
121
+
114
122
  def max_transaction_size
115
123
  Waldit.max_transaction_size
116
124
  end
data/rbi/waldit.rbi CHANGED
@@ -2,7 +2,7 @@
2
2
  module Waldit
3
3
  extend T::Sig
4
4
  extend Waldit::Context
5
- VERSION = "0.0.6"
5
+ VERSION = "0.0.11"
6
6
 
7
7
  class << self
8
8
  sig { returns(String) }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waldit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Navarro
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-08-22 00:00:00.000000000 Z
10
+ date: 2025-08-23 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: wal