logidze 0.6.1 → 0.6.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
  SHA1:
3
- metadata.gz: 9891b1ba6517c7aa789e2244ebed0cac9c749704
4
- data.tar.gz: 49ff3cab8003d957f19c8066a21b194095a5674a
3
+ metadata.gz: 309c5da695723e3a3f1c6e73b5c9ba71826880a8
4
+ data.tar.gz: bab3825e840c655022920bea787059d156643114
5
5
  SHA512:
6
- metadata.gz: fa5d28d3d192210ca6e4b4a2640c075483e59f91cfc214c9211d256d386e733760a103b714135ba33e2bd37ea4e0cd783685f715894cdaa2ae6d3e55641b5e6f
7
- data.tar.gz: 2caed3a94c1244734b3b4c095096152c005f7abce3ded77c4ac832b59dead51a726320e2d88dcb900489df146f5389d9471e8d7a0cf74a74f1ef92c60d87c338
6
+ metadata.gz: 32fc59a0145c74c8334c6990f90481ddece3c3045d79119a260a33d65d6d9236ad54e567fd92dd74705bfb51dc52cea8d0c08356fa1426f15624316a1f6fc882
7
+ data.tar.gz: '080f5c26aa1d1559bdb97b11d141be46e08f6b22f1a1282c07410e75b5b92633aecb2c179490552d1a9e3b61aa113d7c46333e72a753eb80d079fbea1a87c729'
@@ -1,6 +1,8 @@
1
1
  # Change log
2
2
 
3
- ## master
3
+ ## 0.6.2 (2018-01-11)
4
+
5
+ - [Fixes [#53](https://github.com/palkan/logidze/issues/53)] Fix storing empty log entries with blacklisting. ([@charlie-wasp][])
4
6
 
5
7
  ## 0.6.1 (2018-01-06)
6
8
 
data/circle.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  machine:
2
2
  ruby:
3
- version: 2.3.0
3
+ version: 2.5.0
4
4
 
5
5
  environment:
6
6
  DATABASE_URL: postgres://postgres@127.0.0.1:5432/test_database
@@ -112,6 +112,8 @@ class <%= @migration_class_name %> < ActiveRecord::Migration<%= ActiveRecord::VE
112
112
  CREATE OR REPLACE FUNCTION logidze_logger() RETURNS TRIGGER AS $body$
113
113
  DECLARE
114
114
  changes jsonb;
115
+ version jsonb;
116
+ snapshot jsonb;
115
117
  new_v integer;
116
118
  size integer;
117
119
  history_limit integer;
@@ -127,13 +129,19 @@ class <%= @migration_class_name %> < ActiveRecord::Migration<%= ActiveRecord::VE
127
129
  columns_blacklist := TG_ARGV[2];
128
130
 
129
131
  IF TG_OP = 'INSERT' THEN
132
+ snapshot = logidze_snapshot(to_jsonb(NEW.*), ts_column, columns_blacklist);
130
133
 
131
- NEW.log_data := logidze_snapshot(to_jsonb(NEW.*), ts_column, columns_blacklist);
134
+ IF snapshot#>>'{h, -1, c}' != '{}' THEN
135
+ NEW.log_data := snapshot;
136
+ END IF;
132
137
 
133
138
  ELSIF TG_OP = 'UPDATE' THEN
134
139
 
135
140
  IF OLD.log_data is NULL OR OLD.log_data = '{}'::jsonb THEN
136
- NEW.log_data := logidze_snapshot(to_jsonb(NEW.*), ts_column, columns_blacklist);
141
+ snapshot = logidze_snapshot(to_jsonb(NEW.*), ts_column, columns_blacklist);
142
+ IF snapshot#>>'{h, -1, c}' != '{}' THEN
143
+ NEW.log_data := snapshot;
144
+ END IF;
137
145
  RETURN NEW;
138
146
  END IF;
139
147
 
@@ -175,11 +183,16 @@ class <%= @migration_class_name %> < ActiveRecord::Migration<%= ActiveRecord::VE
175
183
  new_v := (NEW.log_data#>>'{h,-1,v}')::int + 1;
176
184
 
177
185
  size := jsonb_array_length(NEW.log_data->'h');
186
+ version := logidze_version(new_v, changes, ts, columns_blacklist);
187
+
188
+ IF version->>'c' = '{}' THEN
189
+ RETURN NEW;
190
+ END IF;
178
191
 
179
192
  NEW.log_data := jsonb_set(
180
193
  NEW.log_data,
181
194
  ARRAY['h', size::text],
182
- logidze_version(new_v, changes, ts, columns_blacklist),
195
+ version,
183
196
  true
184
197
  );
185
198
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Logidze
3
- VERSION = "0.6.1"
3
+ VERSION = "0.6.2"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logidze
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - palkan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-06 00:00:00.000000000 Z
11
+ date: 2018-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails