ree_lib 1.0.28 → 1.0.30

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: 1dee10604487127cc63af20d01924626af8cdd4e5559a1b8716d2065f2ef0c95
4
- data.tar.gz: 742e3d4ec4990eb9989cf904e7fb3eb5ed4eb6d06e5c3791a3188f1ec22cc7b5
3
+ metadata.gz: '0384a60b8e6da77137b281c223ae80df078ad10389876fb719bd6eb7264f305c'
4
+ data.tar.gz: 3771e23d3f69dbb9ba8ff56375b35ee039b92c2132e0398912e32677754f444b
5
5
  SHA512:
6
- metadata.gz: 54aa51badb91b3b3dba8ff6429d3f219bb17e099fb22b0202b6a8a72a65ab0425c56d5237df5fb7a27b8622db2a3f7b453162a6a7d2fc4681acb5c4bda2f840b
7
- data.tar.gz: 75729a0e3b80a7e57e18ba4a3c45a41a96d31dab16868e168e4a31e564166f32b2783ee16c0f4e27412c4edb56d01795875ca5e4d153159d68d71fa961aa3c2e
6
+ metadata.gz: b0e8d42f124e6252ce81fc64a7980c22c85e252ebdcedb5130fcaa53fda721d80c87804e33926251e5da9b753389593252309e5c09a9df4a769399084b0c158d
7
+ data.tar.gz: a8c6acc47b934e848ef7a98ad579b114cd8988bb78872ef5f2c616638e1e6cbe2d64a5618d6efd8fd5dd1ee1000397bab178fe16948617dff574cfa594eb3cf8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree_lib (1.0.28)
4
+ ree_lib (1.0.30)
5
5
  binding_of_caller (~> 1.0.0)
6
6
  i18n (~> 1.12.0)
7
7
  loofah (~> 2.18.0)
@@ -22,7 +22,7 @@ GEM
22
22
  msgpack (~> 1.2)
23
23
  commander (4.6.0)
24
24
  highline (~> 2.0.0)
25
- concurrent-ruby (1.1.10)
25
+ concurrent-ruby (1.2.0)
26
26
  crack (0.4.5)
27
27
  rexml
28
28
  crass (1.0.6)
@@ -36,9 +36,9 @@ GEM
36
36
  crass (~> 1.0.2)
37
37
  nokogiri (>= 1.5.9)
38
38
  msgpack (1.6.0)
39
- nokogiri (1.13.10-x86_64-darwin)
39
+ nokogiri (1.14.1-x86_64-darwin)
40
40
  racc (~> 1.4)
41
- nokogiri (1.13.10-x86_64-linux)
41
+ nokogiri (1.14.1-x86_64-linux)
42
42
  racc (~> 1.4)
43
43
  oj (3.13.23)
44
44
  pg (1.4.5)
@@ -46,7 +46,7 @@ GEM
46
46
  racc (1.6.2)
47
47
  rainbow (3.1.1)
48
48
  rake (13.0.6)
49
- ree (1.0.14)
49
+ ree (1.0.22)
50
50
  commander (~> 4.6.0)
51
51
  rexml (3.2.5)
52
52
  rollbar (3.3.3)
@@ -66,7 +66,7 @@ GEM
66
66
  sequel (5.58.0)
67
67
  sqlite3 (1.4.4)
68
68
  timecop (0.9.6)
69
- tzinfo (2.0.5)
69
+ tzinfo (2.0.6)
70
70
  concurrent-ruby (~> 1.0)
71
71
  webmock (3.18.1)
72
72
  addressable (>= 2.8.0)
@@ -110,29 +110,20 @@ module ReeDao
110
110
  nil
111
111
  end
112
112
 
113
- def update(entity)
114
- if opts[:schema_mapper]
115
- raw = opts[:schema_mapper].db_dump(entity)
116
- raw = extract_changes(entity, raw)
117
-
118
- unless raw.empty?
119
- update_persistence_state(entity, raw)
120
- key_condition = prepare_key_condition_from_entity(entity)
121
- where(key_condition).__original_update(raw)
122
- end
113
+ def update(hash_or_entity)
114
+ return __original_update(hash_or_entity) if !opts[:schema_mapper]
115
+ return __original_update(hash_or_entity) if hash_or_entity.is_a?(Hash)
123
116
 
124
- entity
125
- else
126
- __original_update(entity)
127
- end
128
- end
117
+ raw = opts[:schema_mapper].db_dump(hash_or_entity)
118
+ raw = extract_changes(hash_or_entity, raw)
129
119
 
130
- def update_where(conditions)
131
- __original_update(conditions)
132
- end
120
+ unless raw.empty?
121
+ update_persistence_state(hash_or_entity, raw)
122
+ key_condition = prepare_key_condition_from_entity(hash_or_entity)
123
+ where(key_condition).__original_update(raw)
124
+ end
133
125
 
134
- def delete_where(conditions)
135
- __original_delete(conditions)
126
+ hash_or_entity
136
127
  end
137
128
 
138
129
  def naked_first
@@ -143,13 +134,12 @@ module ReeDao
143
134
  __original_last
144
135
  end
145
136
 
146
- def delete(entity = nil)
147
- if entity
148
- key_condition = prepare_key_condition_from_entity(entity)
149
- where(key_condition).__original_delete
150
- else
151
- __original_delete
152
- end
137
+ def delete(hash_or_entity = nil)
138
+ return __original_delete if hash_or_entity.nil?
139
+ return where(hash_or_entity).__original_delete if hash_or_entity.is_a?(Hash)
140
+
141
+ key_condition = prepare_key_condition_from_entity(hash_or_entity)
142
+ where(key_condition).__original_delete
153
143
  end
154
144
 
155
145
  def with_lock
@@ -25,6 +25,7 @@ class ReeDao::BuildPgConnection
25
25
  sslrootcert?: String,
26
26
  search_path?: String,
27
27
  use_iso_date_format?: Bool,
28
+ max_connections?: Integer,
28
29
  },
29
30
  Ksplat[
30
31
  RestKeys => Any # inherited from `build_connection` opts
@@ -13,6 +13,7 @@ class ReeDao::BuildSqliteConnection
13
13
  database: String,
14
14
  readonly?: Bool,
15
15
  timeout?: Integer,
16
+ max_connections?: Integer,
16
17
  },
17
18
  Ksplat[
18
19
  RestKeys => Any # inherited from `build_connection` opts
@@ -16,7 +16,7 @@
16
16
  "args": [
17
17
  {
18
18
  "arg": "conn_opts",
19
- "type": "{:conn_str? => String, :adapter => String, :database? => String, :encoding? => String, :user? => String, :password? => String, :host? => String, :port? => String, :convert_infinite_timestamps? => Or[string, nil, float], :connect_timeout? => Integer, :driver_options? => Hash, :notice_receiver? => Proc, :sslmode? => Or[disable, allow, prefer, require, verify-ca, verify-full...], :sslrootcert? => String, :search_path? => String, :use_iso_date_format? => Bool}"
19
+ "type": "{:conn_str? => String, :adapter => String, :database? => String, :encoding? => String, :user? => String, :password? => String, :host? => String, :port? => String, :convert_infinite_timestamps? => Or[string, nil, float], :connect_timeout? => Integer, :driver_options? => Hash, :notice_receiver? => Proc, :sslmode? => Or[disable, allow, prefer, require, verify-ca, verify-full...], :sslrootcert? => String, :search_path? => String, :use_iso_date_format? => Bool, :max_connections? => Integer}"
20
20
  },
21
21
  {
22
22
  "arg": "opts",
@@ -16,7 +16,7 @@
16
16
  "args": [
17
17
  {
18
18
  "arg": "conn_opts",
19
- "type": "{:database => String, :readonly? => Bool, :timeout? => Integer}"
19
+ "type": "{:database => String, :readonly? => Bool, :timeout? => Integer, :max_connections? => Integer}"
20
20
  },
21
21
  {
22
22
  "arg": "opts",
@@ -0,0 +1,10 @@
1
+ package_require('ree_dao')
2
+
3
+ RSpec.describe :build_sqlite_connection do
4
+ link :build_sqlite_connection, from: :ree_dao
5
+
6
+ it {
7
+ db = build_sqlite_connection({database: 'sqlite_db', max_connections: 2})
8
+ expect(db.pool.max_size).to eq 2
9
+ }
10
+ end
@@ -227,4 +227,88 @@ RSpec.describe :build_sqlite_connection do
227
227
  expect(dao.count).to eq(1)
228
228
  }
229
229
  end
230
+
231
+ context "update by condition" do
232
+ it {
233
+ dao.delete_all
234
+
235
+ user = ReeDaoTest::User.new(name: 'John', age: 30)
236
+ other_user = ReeDaoTest::User.new(name: 'Steve', age: 30)
237
+ dao.put(user)
238
+ dao.put(other_user)
239
+
240
+ dao.where(name: 'John').update(name: 'Doe')
241
+
242
+ user = dao.find(user.id)
243
+ other_user = dao.find(other_user.id)
244
+ expect(user.name).to eq('Doe')
245
+ expect(other_user.name).to eq('Steve')
246
+ }
247
+ end
248
+
249
+ context "uodate by entity" do
250
+ it {
251
+ dao.delete_all
252
+
253
+ user = ReeDaoTest::User.new(name: 'John', age: 30)
254
+ dao.put(user)
255
+
256
+ user.name = 'Doe'
257
+
258
+ dao.where(name: 'John').update(user)
259
+
260
+ user = dao.find(user.id)
261
+ expect(user.name).to eq('Doe')
262
+ }
263
+ end
264
+
265
+ context "delete by condition" do
266
+ it {
267
+ dao.delete_all
268
+
269
+ user = ReeDaoTest::User.new(name: 'John', age: 30)
270
+ other_user = ReeDaoTest::User.new(name: 'Steve', age: 30)
271
+
272
+ dao.put(user)
273
+ dao.put(other_user)
274
+
275
+ dao.where(name: 'John').delete(name: 'John')
276
+
277
+ user = dao.find(user.id)
278
+ other_user = dao.find(other_user.id)
279
+
280
+ expect(user).to eq(nil)
281
+ expect(other_user.id).to be_a(Integer)
282
+ }
283
+ end
284
+
285
+ context "delete by entity" do
286
+ it {
287
+ dao.delete_all
288
+
289
+ user = ReeDaoTest::User.new(name: 'John', age: 30)
290
+ dao.put(user)
291
+
292
+ user.name = 'Doe'
293
+
294
+ dao.where(name: 'John').delete(user)
295
+
296
+ user = dao.find(user.id)
297
+ expect(user).to eq(nil)
298
+ }
299
+
300
+ it {
301
+ dao.delete_all
302
+
303
+ user = ReeDaoTest::User.new(name: 'John', age: 30)
304
+ dao.put(user)
305
+
306
+ user.name = 'Doe'
307
+
308
+ dao.delete(user)
309
+
310
+ user = dao.find(user.id)
311
+ expect(user).to eq(nil)
312
+ }
313
+ end
230
314
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReeLib
4
- VERSION = "1.0.28"
4
+ VERSION = "1.0.30"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ree_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.28
4
+ version: 1.0.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-10 00:00:00.000000000 Z
11
+ date: 2023-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ree
@@ -260,6 +260,7 @@ files:
260
260
  - lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/one_to_one.schema.json
261
261
  - lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/persist_assoc.schema.json
262
262
  - lib/ree_lib/packages/ree_dao/spec/package_schema_spec.rb
263
+ - lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/build_sqlite_connection/max_connections_spec.rb
263
264
  - lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/build_sqlite_connection_spec.rb
264
265
  - lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/one_to_many_spec.rb
265
266
  - lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/one_to_one_spec.rb