pg_eventstore 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +3 -2
- data/db/migrations/8_drop_events_type.sql +1 -0
- data/lib/pg_eventstore/connection.rb +2 -2
- data/lib/pg_eventstore/pg_connection.rb +29 -0
- data/lib/pg_eventstore/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e22bb2356955ece89a16f5d43b803670d0304eaf27d2fedbf1daf12aa908812
|
4
|
+
data.tar.gz: 31d95e0380be2ad8dd7306a1b04a8a14e6f4f32f6bcdb8864e42205c0a1fe9bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cda13e213beec47c83818301b415d1dbf5b80e0659e548c6d166a3e136172c38802b697353f13344bb0d6b15b99b54f59e950ab9fb2f07e7bf494adedb2c280
|
7
|
+
data.tar.gz: 5f0743afb46b2dcd00c9c164b51beb6f4ea6284b839a0036418d46e60e7d7b8a53d378a1eb265fc063364970ae6fb2b0091fabae51429775bec2f8c1c2e843fa
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [0.3.0] - 2024-01-24
|
2
|
+
|
3
|
+
- Log SQL queries when `PgEvenstore.logger` is set and it is in `:debug` mode
|
4
|
+
|
5
|
+
## [0.2.6] - 2023-12-20
|
6
|
+
|
7
|
+
- Remove `events.type` column
|
8
|
+
|
1
9
|
## [0.2.5] - 2023-12-20
|
2
10
|
|
3
11
|
- Fix bug when migrations files are returned in unsorted order on some systems
|
data/README.md
CHANGED
@@ -4,8 +4,9 @@ Implements database and API to store and read events in event sourced systems.
|
|
4
4
|
|
5
5
|
## Requirements
|
6
6
|
|
7
|
-
`pg_eventstore` requires a PostgreSQL database with jsonb data type support (which means you need to have v9.2+). However it is recommended to use a non [EOL](https://www.postgresql.org/support/versioning/) PostgreSQL version, because the development of this gem is targeted at current PostgreSQL versions.
|
8
|
-
`
|
7
|
+
- `pg_eventstore` requires a PostgreSQL database with jsonb data type support (which means you need to have v9.2+). However it is recommended to use a non [EOL](https://www.postgresql.org/support/versioning/) PostgreSQL version, because the development of this gem is targeted at current PostgreSQL versions.
|
8
|
+
- It is recommend you to have the default value set for `default_transaction_isolation` PostgreSQL config setting(`"read committed"`) as the implementation relies on it. All other transaction isolation levels(`"repeatable read"` and `"serializable"`) may cause unexpected serialization errors which you will have to handle by yourself(e.g. by always wrapping your code using [`#multiple`](docs/multiple_commands.md)).
|
9
|
+
- `pg_eventstore` requires ruby v3+. The development of this gem is targeted at [current](https://endoflife.date/ruby) ruby versions.
|
9
10
|
|
10
11
|
## Installation
|
11
12
|
|
@@ -0,0 +1 @@
|
|
1
|
+
ALTER TABLE public.events DROP COLUMN type;
|
@@ -4,6 +4,7 @@ require 'pg'
|
|
4
4
|
require 'pg/basic_type_map_for_results'
|
5
5
|
require 'pg/basic_type_map_for_queries'
|
6
6
|
require 'connection_pool'
|
7
|
+
require_relative 'pg_connection'
|
7
8
|
|
8
9
|
module PgEventstore
|
9
10
|
class Connection
|
@@ -73,10 +74,9 @@ module PgEventstore
|
|
73
74
|
# @return [ConnectionPool]
|
74
75
|
def init_pool
|
75
76
|
@pool ||= ConnectionPool.new(size: pool_size, timeout: pool_timeout) do
|
76
|
-
|
77
|
+
PgConnection.new(uri).tap do |conn|
|
77
78
|
conn.type_map_for_results = PG::BasicTypeMapForResults.new(conn, registry: pg_type_registry)
|
78
79
|
conn.type_map_for_queries = PG::BasicTypeMapForQueries.new(conn, registry: pg_type_registry)
|
79
|
-
# conn.trace($stdout) # logs
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PgEventstore
|
4
|
+
class PgConnection < PG::Connection
|
5
|
+
def exec(sql)
|
6
|
+
log(sql, [])
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def exec_params(sql, params, ...)
|
11
|
+
log(sql, params)
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def log(sql, params)
|
18
|
+
return unless PgEventstore.logger&.debug?
|
19
|
+
|
20
|
+
sql = sql.gsub(/\$\d+/).each do |matched|
|
21
|
+
value = params[matched[1..].to_i - 1]
|
22
|
+
|
23
|
+
value = type_map_for_queries[value.class]&.encode(value) || value
|
24
|
+
value.is_a?(String) ? "'#{value}'" : value
|
25
|
+
end unless params&.empty?
|
26
|
+
PgEventstore.logger.debug(sql)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_eventstore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Dzyzenko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- db/migrations/5_adjust_indexes.sql
|
62
62
|
- db/migrations/6_change_events_event_type_id_null_constraint.sql
|
63
63
|
- db/migrations/7_change_events_type_constraint.sql
|
64
|
+
- db/migrations/8_drop_events_type.sql
|
64
65
|
- docs/appending_events.md
|
65
66
|
- docs/configuration.md
|
66
67
|
- docs/events_and_streams.md
|
@@ -82,6 +83,7 @@ files:
|
|
82
83
|
- lib/pg_eventstore/event_serializer.rb
|
83
84
|
- lib/pg_eventstore/extensions/options_extension.rb
|
84
85
|
- lib/pg_eventstore/middleware.rb
|
86
|
+
- lib/pg_eventstore/pg_connection.rb
|
85
87
|
- lib/pg_eventstore/pg_result_deserializer.rb
|
86
88
|
- lib/pg_eventstore/queries.rb
|
87
89
|
- lib/pg_eventstore/queries/event_queries.rb
|