entity_store_sequel 0.0.3 → 0.0.4

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: 0feccb2b1600da42b28dc1af3ce9b12ab524f5d1
4
- data.tar.gz: 0abc11734ddac5a20f95fae45aa149b4b99e6f56
3
+ metadata.gz: fe8f1e8c880574aeebde6c43890593d73200dc8d
4
+ data.tar.gz: cb9f6616a8988e4f107ea78e356c4a7777be73da
5
5
  SHA512:
6
- metadata.gz: e02bb1ea78b18e8179e0462421b829970b3f3456c76cef9bfeee6197d1e6c764cd07ac40fc196dcfe891827363c0e24f2fbef012a3e8365abeac2bc000be57c4
7
- data.tar.gz: 371f759a2eded9956d604abbc7bf1baf8358a2b05829e844cbc46d86ed778d25ab9fbc5432f7b7f471492c358e4f27270706019099ca1f6b785dfb39a8e1e47a
6
+ metadata.gz: 8915e37a1aebe087fcfad8aacfb2dca9a689ffc7f9925c875cccae6cb0f7189e3236e299bedee83260ac97f551d118eb2d712e3cda764dedf372ecb7076606bf
7
+ data.tar.gz: 48a09251efe792521648e169aee81d692b2b9f2a669bb42fc87cc95ba451150b27f68009121da5ab7b5e0abb5154b47e745da6c019c63661f95184bed2e96ec6
@@ -8,13 +8,12 @@ module EntityStoreSequel
8
8
  class PostgresEntityStore
9
9
  include EntityStore::Logging
10
10
 
11
- Sequel.extension :pg_array_ops
12
- Sequel.extension :pg_json_ops
13
11
  Sequel.extension :migration
14
12
 
15
13
  class << self
16
14
  attr_accessor :connection_string
17
15
  attr_writer :connect_timeout
16
+ attr_accessor :native_json_hash
18
17
 
19
18
  def database
20
19
  return @_database if @_database
@@ -24,8 +23,13 @@ module EntityStoreSequel
24
23
 
25
24
  def database=(db)
26
25
  @_database = db
27
- @_database.extension :pg_array
28
- @_database.extension :pg_json
26
+
27
+ if db.adapter_scheme == :postgres
28
+ @_database.extension :pg_json
29
+ self.native_json_hash = true
30
+ else
31
+ self.native_json_hash = false
32
+ end
29
33
 
30
34
  @_database
31
35
  end
@@ -155,7 +159,12 @@ module EntityStoreSequel
155
159
  end
156
160
 
157
161
  if attrs[:snapshot]
158
- hash = attrs[:snapshot].to_h
162
+ if self.class.native_json_hash
163
+ hash = attrs[:snapshot].to_h
164
+ else
165
+ hash = PigeonHole.parse(attrs[:snapshot])
166
+ end
167
+
159
168
  entity = entity_type.new(hash)
160
169
  else
161
170
  entity = entity_type.new({'id' => attrs[:id].to_s })
@@ -198,7 +207,12 @@ module EntityStoreSequel
198
207
 
199
208
  result[item[:id]] = query.order(:entity_version, :id).map do |attrs|
200
209
  begin
201
- hash = attrs[:data].to_h
210
+ if self.class.native_json_hash
211
+ hash = attrs[:data].to_h
212
+ else
213
+ hash = PigeonHole.parse(attrs[:data])
214
+ end
215
+
202
216
  hash[:_id] = attrs[:id]
203
217
  hash[:entity_version] = attrs[:entity_version]
204
218
  EntityStore::Config.load_type(attrs[:_type]).new(hash)
@@ -1,3 +1,3 @@
1
1
  module EntityStoreSequel
2
- VERSION = "0.0.3".freeze
2
+ VERSION = "0.0.4".freeze
3
3
  end
@@ -217,7 +217,7 @@ describe PostgresEntityStore do
217
217
  store.entities.where(:id => entity.id).first
218
218
  end
219
219
 
220
- let(:snapshot) { saved_entity[:snapshot] }
220
+ let(:snapshot) { saved_entity[:snapshot].to_h }
221
221
 
222
222
  subject { store.snapshot_entity(entity) }
223
223
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: entity_store_sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Binns
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-12 00:00:00.000000000 Z
11
+ date: 2016-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -24,34 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: pg
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: sequel_pg
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: entity_store
57
29
  requirement: !ruby/object:Gem::Requirement