ruby_event_store-active_record 2.12.1 → 2.13.0

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: c9c93dedba2d77d5d9a3b8d72346baae945137d0a454435533114cbc7a12dfe8
4
- data.tar.gz: 6a2c214fd8433e874b25f29e5a34ebd7ddc58fe2b0368573bba94bdd919b2f9f
3
+ metadata.gz: 844a72fb4397a85af4951552a503d02f3f46fee88add52b3d4da559da0a578e1
4
+ data.tar.gz: c09cd8f7af18e4b3a276c09efa2a31f4e3ee5e62d29394f7022ab83ab7763ae5
5
5
  SHA512:
6
- metadata.gz: 723e4cf7240697d8615a65fd2af425650df2b61274857e49665c82a4cf7d8916a904bb7ce3d9f0126955c7da96e43d2f3518e0ed2025170df14cccdde18487c2
7
- data.tar.gz: 6ed6cafb966c3a2d60df79fdf4a192f39d32f2425375b5b23c6a51166482663dcf554d16f5e9cf24d227d784242495fba68679419fdb3597d7a859f9c5207fec
6
+ metadata.gz: 523f386852a08972217416c04335113e99f8c9bbe167100aed3035bc39e866f83d4cafb59d270ef314fbe974f2e1f23090479407eabe6bb44cf39382e0e953a8
7
+ data.tar.gz: a1974be5b9e5fe233e9dc27f23e98b4140bc51dced795a61f1cfc714d3af959c6fc6a5da40fd6c5cd508f408fa5a24b2840e7e06a435807c981cd2887ba9133c
@@ -17,8 +17,8 @@ module RubyEventStore
17
17
  batch_limit = [batch_size, total_limit - batch_offset].min
18
18
  results, offset_id = reader.call(offset_id, batch_limit)
19
19
 
20
- break if results.empty?
21
- yield results
20
+ yield results if results.any?
21
+ break if results.size < batch_size
22
22
  end
23
23
  end
24
24
 
@@ -96,7 +96,7 @@ module RubyEventStore
96
96
  stream = stream.where(newer_than_or_equal_condition(spec)) if spec.newer_than_or_equal
97
97
  stream.order(id: order(spec))
98
98
  else
99
- stream = @stream_klass.preload(:event).where(stream: spec.stream.name)
99
+ stream = @stream_klass.includes(:event).where(stream: spec.stream.name)
100
100
  stream = stream.where(event_id: spec.with_ids) if spec.with_ids?
101
101
  stream = stream.joins(:event).where(@event_klass.table_name => { event_type: spec.with_types }) if spec.with_types?
102
102
  stream = stream.joins(:event).order(as_at(spec)) if spec.time_sort_by_as_at?
@@ -6,13 +6,13 @@ module RubyEventStore
6
6
  InvalidDataTypeForAdapter = Class.new(StandardError)
7
7
 
8
8
  class DatabaseAdapter
9
- NOT_SET = Object.new.freeze
9
+ NONE = Object.new.freeze
10
10
 
11
11
  class PostgreSQL < self
12
12
  SUPPORTED_DATA_TYPES = %w[binary json jsonb].freeze
13
13
 
14
- def initialize(data_type = NOT_SET)
15
- super("postgresql", data_type)
14
+ def adapter_name
15
+ "postgresql"
16
16
  end
17
17
 
18
18
  def template_directory
@@ -23,8 +23,8 @@ module RubyEventStore
23
23
  class MySQL < self
24
24
  SUPPORTED_DATA_TYPES = %w[binary json].freeze
25
25
 
26
- def initialize(data_type = NOT_SET)
27
- super("mysql2", data_type)
26
+ def adapter_name
27
+ "mysql2"
28
28
  end
29
29
 
30
30
  def template_directory
@@ -35,21 +35,20 @@ module RubyEventStore
35
35
  class SQLite < self
36
36
  SUPPORTED_DATA_TYPES = %w[binary].freeze
37
37
 
38
- def initialize(data_type = NOT_SET)
39
- super("sqlite", data_type)
38
+ def adapter_name
39
+ "sqlite"
40
40
  end
41
41
  end
42
42
 
43
- def initialize(adapter_name, data_type)
43
+ def initialize(data_type = NONE)
44
44
  raise UnsupportedAdapter if instance_of?(DatabaseAdapter)
45
45
 
46
46
  validate_data_type!(data_type)
47
47
 
48
- @adapter_name = adapter_name
49
48
  @data_type = data_type
50
49
  end
51
50
 
52
- attr_reader :adapter_name, :data_type
51
+ attr_reader :data_type
53
52
 
54
53
  def supported_data_types
55
54
  self.class::SUPPORTED_DATA_TYPES
@@ -68,7 +67,7 @@ module RubyEventStore
68
67
  def template_directory
69
68
  end
70
69
 
71
- def self.from_string(adapter_name, data_type = NOT_SET)
70
+ def self.from_string(adapter_name, data_type = NONE)
72
71
  raise NoMethodError unless eql?(DatabaseAdapter)
73
72
 
74
73
  case adapter_name.to_s.downcase
@@ -86,7 +85,7 @@ module RubyEventStore
86
85
  private
87
86
 
88
87
  def validate_data_type!(data_type)
89
- if !data_type.eql?(NOT_SET) && !supported_data_types.include?(data_type)
88
+ if !data_type.eql?(NONE) && !supported_data_types.include?(data_type)
90
89
  raise InvalidDataTypeForAdapter,
91
90
  "#{class_name} doesn't support #{data_type.inspect}. Supported types are: #{supported_data_types.join(", ")}."
92
91
  end
@@ -45,10 +45,6 @@ module RubyEventStore
45
45
  ::ActiveRecord::Migration.current_version
46
46
  end
47
47
 
48
- def timestamp
49
- Time.now.strftime("%Y%m%d%H%M%S")
50
- end
51
-
52
48
  def write_to_file(path, migration_code)
53
49
  File.write(path, migration_code)
54
50
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RubyEventStore
4
4
  module ActiveRecord
5
- VERSION = "2.12.1"
5
+ VERSION = "2.13.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_event_store-active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.12.1
4
+ version: 2.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arkency
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-05 00:00:00.000000000 Z
11
+ date: 2023-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby_event_store
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.12.1
19
+ version: 2.13.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.12.1
26
+ version: 2.13.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement