ree_lib 1.0.29 → 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0384a60b8e6da77137b281c223ae80df078ad10389876fb719bd6eb7264f305c'
|
4
|
+
data.tar.gz: 3771e23d3f69dbb9ba8ff56375b35ee039b92c2132e0398912e32677754f444b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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)
|
@@ -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.14.
|
39
|
+
nokogiri (1.14.1-x86_64-darwin)
|
40
40
|
racc (~> 1.4)
|
41
|
-
nokogiri (1.14.
|
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.
|
49
|
+
ree (1.0.22)
|
50
50
|
commander (~> 4.6.0)
|
51
51
|
rexml (3.2.5)
|
52
52
|
rollbar (3.3.3)
|
@@ -110,29 +110,20 @@ module ReeDao
|
|
110
110
|
nil
|
111
111
|
end
|
112
112
|
|
113
|
-
def update(
|
114
|
-
if opts[:schema_mapper]
|
115
|
-
|
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
|
-
|
125
|
-
|
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
|
-
|
131
|
-
|
132
|
-
|
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
|
-
|
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(
|
147
|
-
if
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
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
|
@@ -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
|
data/lib/ree_lib/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2023-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ree
|