logidze 1.2.1 → 1.2.3

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: be9e11a375ab711ba02349e3cd14fbd4503af6572d969ced6db24bd36407bf05
4
- data.tar.gz: '03885f890051fc938cba4089798bcc8b1b753a5ae941c5d93907536e1685ff94'
3
+ metadata.gz: ac315542fe9ec1866a4395ed04f1e431d65fe6c9dfc72874a423224c0b52b3cb
4
+ data.tar.gz: deb4efcba8179273185738fbe395458f6bd4165bf8ed1263b0348bf9bc4b45ab
5
5
  SHA512:
6
- metadata.gz: 24bc6a181263eaeb98762e8c183ba74b717a3195d2809460ceeddfbeefdc63c4b72e3c5da2b8426bba2722c765a41c27bf3ff2d3e265b5760a561795e205ee5a
7
- data.tar.gz: 96f0e22ccad449d642320a9bf105e05ed15623ecaa1a52e453bfda356df2dbf9cb13eda235c6e288e1cf62d0484234f92104673c7ef15c9fbfe135d8bb757b16
6
+ metadata.gz: bffd04a3005c169a56e3280eaceb7c22623b7d7cfdf82719d65f16804fd86adee32f9afdccd6e767923dd5f6b0b63c0354455ad5daba7a608a420190cae4c2fd
7
+ data.tar.gz: c7296b56fed241dc7f55a16a5307b596f1ec016f334cb743c47272295db3ee4d1236bbda0f97c78a9b4a8e50309e07757322611c41bb5386bdbee3500fa57a1b
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 1.2.3 (2023-01-03)
6
+
7
+ - [Fixes [#217](https://github.com/palkan/logidze/issues/217)] Fix switch_to with `append: true` when there are changes on JSONB columns. ([@miharekar][])
8
+
9
+ ## 1.2.2 (2022-07-13)
10
+
11
+ - [Fixes [#209](https://github.com/palkan/logidze/issues/209)] Fix tracking JSONB column changes. ([@baygeldin][])
12
+
5
13
  ## 1.2.1 (2022-01-13)
6
14
 
7
15
  - [Fixes [#207](https://github.com/palkan/logidze/issues/207)] Add support for the use of `table_name_prefix` or `table_name_suffix`. ([@cavi21][])
@@ -62,7 +70,7 @@ now we filter the columns within the trigger function (thus, schema changes do n
62
70
 
63
71
  - PR [#143](https://github.com/palkan/logidze/pull/143) Add `:transactional` option to `#with_meta` and `#with_responsible` ([@oleg-kiviljov][])
64
72
 
65
- Now it's possible to set meta and responsible without wrapping the block into a DB transaction. For backward compatibility `:transactional` option by default is set to `true`.
73
+ Now it's possible to set meta and responsible without wrapping the block into a DB transaction. For backward compatibility `:transactional` option by default is set to `true`.
66
74
 
67
75
  Usage:
68
76
 
@@ -367,3 +375,4 @@ This is a quick fix for a more general problem (see [#59](https://github.com/pal
367
375
  [@bf4]: https://github.com/bf4
368
376
  [@cavi21]: https://github.com/cavi21
369
377
  [@danielmklein]: https://github.com/danielmklein
378
+ [@baygeldin]: https://github.com/baygeldin
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016-2020 Vladimir Dementyev
3
+ Copyright (c) 2016-2023 Vladimir Dementyev
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -485,7 +485,7 @@ $ bundle exec rails generate logidze:model Post --update --only=title,body,ratin
485
485
 
486
486
  ### Pending upgrade check [Experimental]
487
487
 
488
- Logidze can check for a pending upgrade. Use `Logidze.on_pending_upgrade = :warn` to be notified by warning, or `Logidze.on_pending_upgrade = :error` if you want Logidze to raise an error.
488
+ Logidze can check for a pending upgrade. Use `Logidze.on_pending_upgrade = :warn` to be notified by warning, or `Logidze.on_pending_upgrade = :raise` if you want Logidze to raise an error.
489
489
 
490
490
  ### Upgrading from 0.x to 1.0 (edge)
491
491
 
@@ -1,5 +1,5 @@
1
1
  CREATE OR REPLACE FUNCTION logidze_logger() RETURNS TRIGGER AS $body$
2
- -- version: 2
2
+ -- version: 3
3
3
  DECLARE
4
4
  changes jsonb;
5
5
  version jsonb;
@@ -70,7 +70,7 @@ CREATE OR REPLACE FUNCTION logidze_logger() RETURNS TRIGGER AS $body$
70
70
  END IF;
71
71
  END IF;
72
72
 
73
- IF NEW = OLD THEN
73
+ IF to_jsonb(NEW.*) = to_jsonb(OLD.*) THEN
74
74
  RETURN NEW;
75
75
  END IF;
76
76
 
data/lib/logidze/model.rb CHANGED
@@ -172,10 +172,14 @@ module Logidze
172
172
  # Restore record to the specified version.
173
173
  # Return false if version is unknown.
174
174
  def switch_to!(version, append: Logidze.append_on_undo)
175
+ raise ArgumentError, "#log_data is empty" unless log_data
176
+
175
177
  return false unless at_version(version)
176
178
 
177
179
  if append && version < log_version
178
- update!(log_data.changes_to(version: version))
180
+ changes = log_data.changes_to(version: version)
181
+ changes.each { |c, v| changes[c] = deserialize_value(c, v) }
182
+ update!(changes)
179
183
  else
180
184
  at_version!(version)
181
185
  self.class.without_logging { save! }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Logidze
4
- VERSION = "1.2.1"
4
+ VERSION = "1.2.3"
5
5
  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: 1.2.1
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - palkan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-13 00:00:00.000000000 Z
11
+ date: 2023-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -216,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
216
  - !ruby/object:Gem::Version
217
217
  version: '0'
218
218
  requirements: []
219
- rubygems_version: 3.2.22
219
+ rubygems_version: 3.3.11
220
220
  signing_key:
221
221
  specification_version: 4
222
222
  summary: PostgreSQL JSONB-based model changes tracking