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 +4 -4
- data/README.md +2 -2
- data/lib/waldit/railtie.rb +10 -7
- data/lib/waldit/version.rb +1 -1
- data/lib/waldit/watcher.rb +11 -3
- data/rbi/waldit.rbi +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3cb369606cb9c2a97b853b3f0d219c015cc92fdf0fcbbdb8089de5292fcebd9
|
4
|
+
data.tar.gz: d8a1c90d307333c38bae27e66164dbbd81f069b97bc6af390959802b073d6ca7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 `
|
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:
|
38
|
+
adapter: waldit
|
39
39
|
# ...
|
40
40
|
```
|
41
41
|
|
data/lib/waldit/railtie.rb
CHANGED
@@ -5,13 +5,16 @@ require "rails/railtie"
|
|
5
5
|
module Waldit
|
6
6
|
class Railtie < Rails::Railtie
|
7
7
|
config.before_configuration do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
data/lib/waldit/version.rb
CHANGED
data/lib/waldit/watcher.rb
CHANGED
@@ -13,18 +13,22 @@ module Waldit
|
|
13
13
|
|
14
14
|
case event
|
15
15
|
when InsertEvent
|
16
|
-
|
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
|
-
|
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
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.
|
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-
|
10
|
+
date: 2025-08-23 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: wal
|