event_store 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTgxNzVkNDg1ZTRiYTYxYmExMTQwYTExZTViMWNmM2E5NzkxMzQ0MA==
4
+ MTc5NmM1ODQ2NTAwNWM4YzRmM2EzNTAzZjNmYjg3OTM4YThiYmIxMQ==
5
5
  data.tar.gz: !binary |-
6
- NGNlZTcwMDdkNjcyYmQyMmVlMDY1NTRiNDc5MGVkNmM5ZTMwNWVhMA==
6
+ YmEyNWViZTUwMDE2MzE1ZDM5NmI0NjUzMGRhNjYyNmQ0N2EzODExNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MGRhZjc4MzU5ZjlmMGIzOTgxNmU5NjQ3NzVhYjhkNzViMWFkNWI5NmY2MmE3
10
- MGM4ZmQxNDVkZTBlMmQ4MmIzOTVlYzNkMGI5NTM3YTEzODdlN2RjZjUzMGFj
11
- ZTIxZDA4OGM5OGM2Mjc4NWE4N2E3NmNiMGRmZmUwN2UyNjI3YmI=
9
+ YmRkOWYyMjdhMTQ2OTM2YzUzZjY2NWYwMWI4NDA2NTQ5ODNlOGE5OWViM2Q0
10
+ NTQ4MjUwNzdlYTY0MWRjNjAzNThhMDFjMGUxMTQ1YzRjNTdjMWNkZGY5Yzkx
11
+ NTc3ODE1ODU2NWQ4M2VkNDQxNmY3YjNjNzU3YWFiMjQ0M2E2MjY=
12
12
  data.tar.gz: !binary |-
13
- MWFjYjRiYWY4NDY5ZDRhZmZlYjMxZGQ5M2NiNjlmZmIwNDQ3MTFhN2JkOWEw
14
- YWJiOGFmYTVjNzQzZTlkZmE2ZmIzMDYzZDRkNDM3YjJhZDAyYjQwYWYzMzM3
15
- NDUyMjIwYzE0MGM1MDc2YWVlNTZjYjc4ZTgyMzVlNTQ2YzkwMzY=
13
+ NzYxMzE0MWU3ZTcxMDlhYTU2Y2IwZmM2NzFiMDg0NWRhZjBiOWExZDZkODk0
14
+ MTZlNDY0NmE3M2RjZDdkNjFiYWI4ZWY4NDJiNzc1Y2UxMzhlYTM2ZmQ2NzBi
15
+ OTVjMjY0NGNmNGMzNjlmMzA2NmVjYjM3ODc0ZjVmY2RiYWJkMWY=
@@ -99,16 +99,11 @@ module EventStore
99
99
  end
100
100
 
101
101
  def self.escape_bytea(binary_string)
102
- @adapter == 'vertica' ? binary_string.unpack('H*').join : EventStore.db.literal(binary_string.to_sequel_blob)
102
+ binary_string.unpack('H*').join
103
103
  end
104
104
 
105
105
  def self.unescape_bytea(binary_string)
106
- if @adapter == 'vertica'
107
- [binary_string].pack("H*")
108
- else
109
- unescaped = Sequel::Postgres::Adapter.unescape_bytea(binary_string)
110
- unescaped[0] == "'" && unescaped[-1] == "'" ? unescaped[1...-1] : unescaped #postgres adds an extra set of quotes when you insert it, Redis does not. Therefore we need to pull off the extra quotes if they are there
111
- end
106
+ [binary_string].pack("H*")
112
107
  end
113
108
 
114
109
  def self.custom_config(database_config, redis_config, table_name = 'events', environment = 'production')
@@ -138,4 +133,4 @@ module EventStore
138
133
  def self.vertica_host
139
134
  File.read File.expand_path(File.join('..','..','db', 'vertica_host_address.txt'), __FILE__)
140
135
  end
141
- end
136
+ end
@@ -45,7 +45,10 @@ module EventStore
45
45
  end
46
46
 
47
47
  def events_from(version_number, max = nil)
48
- events.limit(max).where{ version >= version_number.to_i }.all
48
+ events.limit(max).where{ version >= version_number.to_i }.all.map do |event|
49
+ event[:serialized_event] = EventStore.unescape_bytea(event[:serialized_event])
50
+ event
51
+ end
49
52
  end
50
53
 
51
54
  def event_stream_between(start_time, end_time, fully_qualified_names = [])
@@ -1,3 +1,3 @@
1
1
  module EventStore
2
- VERSION = "0.2.8"
2
+ VERSION = "0.2.9"
3
3
  end
@@ -78,6 +78,25 @@ describe EventStore::Client do
78
78
  stream = es_client.new(AGGREGATE_ID_ONE, :device).event_stream
79
79
  expect(stream.count).to eq(10)
80
80
  end
81
+
82
+ context "when the serialized event is terminated prematurely with a null byte" do
83
+ it "does not truncate the serialized event when there is a binary zero value is at the end" do
84
+ serialized_event = serialized_event_data_terminated_by_null
85
+ client = es_client.new("any_device", :device)
86
+ event = EventStore::Event.new("any_device", @event_time, 'other_event_name', serialized_event, client.version + 1)
87
+ client.append([event])
88
+ expect(client.event_stream.last[:serialized_event]).to eql(serialized_event)
89
+ end
90
+
91
+ it "conversion of byte array to and from hex should be lossless" do
92
+ client = es_client.new("any_device", :device)
93
+ serialized_event = serialized_event_data_terminated_by_null
94
+ event = EventStore::Event.new("any_device", @event_time, 'terminated_by_null_event', serialized_event, client.version + 1)
95
+ client.append([event])
96
+ hex_from_db = EventStore.db.from(EventStore.fully_qualified_table).where(fully_qualified_name: 'terminated_by_null_event').first[:serialized_event]
97
+ expect(hex_from_db).to eql(EventStore.escape_bytea(serialized_event))
98
+ end
99
+ end
81
100
  end
82
101
 
83
102
 
@@ -380,6 +399,10 @@ describe EventStore::Client do
380
399
  end
381
400
 
382
401
  end
402
+ def serialized_event_data_terminated_by_null
403
+ @term_data ||= File.open(File.expand_path("../binary_string_term_with_null_byte.txt", __FILE__), 'rb') {|f| f.read}
404
+ @term_data
405
+ end
383
406
  def serialized_binary_event_data
384
407
  @event_data ||= File.open(File.expand_path("../serialized_binary_event_data.txt", __FILE__), 'rb') {|f| f.read}
385
408
  @event_data
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Saieg, John Colvin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-05 00:00:00.000000000 Z
12
+ date: 2014-05-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -240,6 +240,7 @@ files:
240
240
  - spec/benchmark/bench.rb
241
241
  - spec/benchmark/memory_profile.rb
242
242
  - spec/benchmark/seed_db.rb
243
+ - spec/event_store/binary_string_term_with_null_byte.txt
243
244
  - spec/event_store/client_spec.rb
244
245
  - spec/event_store/config_spec.rb
245
246
  - spec/event_store/serialized_binary_event_data.txt
@@ -274,6 +275,7 @@ test_files:
274
275
  - spec/benchmark/bench.rb
275
276
  - spec/benchmark/memory_profile.rb
276
277
  - spec/benchmark/seed_db.rb
278
+ - spec/event_store/binary_string_term_with_null_byte.txt
277
279
  - spec/event_store/client_spec.rb
278
280
  - spec/event_store/config_spec.rb
279
281
  - spec/event_store/serialized_binary_event_data.txt