waldit 0.0.10 → 0.0.12

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: 36a418e6018778b191932f3ae0a024f249dadf81650680cc638e09582ae2cbf1
4
- data.tar.gz: be6287122656902fd53defba9430506bed0c0039464c4a212457f552b9a94f27
3
+ metadata.gz: a3cb369606cb9c2a97b853b3f0d219c015cc92fdf0fcbbdb8089de5292fcebd9
4
+ data.tar.gz: d8a1c90d307333c38bae27e66164dbbd81f069b97bc6af390959802b073d6ca7
5
5
  SHA512:
6
- metadata.gz: 5fbf80049a20bbb4f2bce49f2eadbc725f9ccca4555f7977581d33509ac3c50910e49766a6b10da0733c71d7b3dabd889a8276ce71f55a6519b3ce908cf37f49
7
- data.tar.gz: 73a975b25ca05a32a34448bc96fa06eb57825f10eac3dea592b3a0e179b07126d501261c8d078f65c60d03aa59b724223a6d1c14b61583cb2962cf8f65a42042
6
+ metadata.gz: ef09522f4b9b1bb22794726625491a04784b402ff38f8da791349b36bed4fae5d5764e4c5493b6b571ee3b0b05350efb178b8793a3201ad0989851ae32e7e9d2
7
+ data.tar.gz: 50b8c47faff3cd316f4dabd84221d9729484f41720d27d7768bae44539ec4058d840ca183e74eca9583119ecc8fe24c7429416460c392f6e76d43b1c24529cb8
data/README.md CHANGED
@@ -31,11 +31,11 @@ Or install it yourself as:
31
31
 
32
32
  1. **Configure your database adapter:**
33
33
 
34
- First step is to configure in your `config/database.yml` and change your adapter to `postgresqlwaldit`, which is a special adapter that allows injecting `waldit` contextual information on your transactions:
34
+ First step is to configure in your `config/database.yml` and change your adapter to `waldit`, which is a special adapter that allows injecting `waldit` contextual information on your transactions:
35
35
 
36
36
  ```yaml
37
37
  default: &default
38
- adapter: postgresqlwaldit
38
+ adapter: waldit
39
39
  # ...
40
40
  ```
41
41
 
@@ -5,13 +5,16 @@ require "rails/railtie"
5
5
  module Waldit
6
6
  class Railtie < Rails::Railtie
7
7
  config.before_configuration do
8
- ["waldit", "postgresqlwaldit"].each do |adapter_name|
9
- ActiveRecord::ConnectionAdapters.register(
10
- adapter_name,
11
- "Waldit::PostgreSQLAdapter",
12
- "waldit/postgresql_adapter",
13
- )
14
- end
8
+ ActiveRecord::ConnectionAdapters.register(
9
+ "waldit",
10
+ "Waldit::PostgreSQLAdapter",
11
+ "waldit/postgresql_adapter",
12
+ )
13
+
14
+ ActiveRecord::Tasks::DatabaseTasks.register_task(
15
+ "waldit",
16
+ "ActiveRecord::Tasks::PostgreSQLDatabaseTasks",
17
+ )
15
18
 
16
19
  require_relative "migration"
17
20
  ActiveRecord::Migration.include Waldit::Migration
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Waldit
4
- VERSION = "0.0.10"
4
+ VERSION = "0.0.12"
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.12"
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.10
4
+ version: 0.0.12
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