datamappify 0.60.0 → 0.70.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/CHANGELOG.md +20 -0
- data/README.md +120 -3
- data/datamappify.gemspec +3 -3
- data/lib/datamappify/data/criteria/active_record/count.rb +0 -2
- data/lib/datamappify/data/criteria/active_record/criteria.rb +10 -0
- data/lib/datamappify/data/criteria/active_record/criteria_method.rb +65 -0
- data/lib/datamappify/data/criteria/active_record/find.rb +10 -2
- data/lib/datamappify/data/criteria/active_record/find_by_key.rb +4 -2
- data/lib/datamappify/data/criteria/active_record/limit.rb +10 -0
- data/lib/datamappify/data/criteria/active_record/match.rb +40 -0
- data/lib/datamappify/data/criteria/active_record/order.rb +41 -0
- data/lib/datamappify/data/criteria/active_record/rollback.rb +13 -0
- data/lib/datamappify/data/criteria/active_record/save.rb +1 -4
- data/lib/datamappify/data/criteria/active_record/save_by_key.rb +0 -1
- data/lib/datamappify/data/criteria/active_record/where.rb +18 -0
- data/lib/datamappify/data/criteria/common.rb +5 -2
- data/lib/datamappify/data/criteria/concerns/update_primary_record.rb +2 -0
- data/lib/datamappify/data/criteria/relational/concerns/find.rb +35 -0
- data/lib/datamappify/data/criteria/relational/concerns/find_by_key.rb +19 -0
- data/lib/datamappify/data/criteria/relational/criteria.rb +29 -0
- data/lib/datamappify/data/criteria/relational/{find_multiple.rb → criteria_base_method.rb} +2 -28
- data/lib/datamappify/data/criteria/relational/criteria_method.rb +44 -0
- data/lib/datamappify/data/criteria/relational/limit.rb +13 -0
- data/lib/datamappify/data/criteria/relational/save.rb +12 -0
- data/lib/datamappify/data/criteria/sequel/count.rb +0 -2
- data/lib/datamappify/data/criteria/sequel/criteria.rb +10 -0
- data/lib/datamappify/data/criteria/sequel/criteria_method.rb +51 -0
- data/lib/datamappify/data/criteria/sequel/find.rb +10 -2
- data/lib/datamappify/data/criteria/sequel/find_by_key.rb +4 -2
- data/lib/datamappify/data/criteria/sequel/limit.rb +10 -0
- data/lib/datamappify/data/criteria/sequel/match.rb +22 -0
- data/lib/datamappify/data/criteria/sequel/order.rb +22 -0
- data/lib/datamappify/data/criteria/sequel/rollback.rb +13 -0
- data/lib/datamappify/data/criteria/sequel/save.rb +1 -4
- data/lib/datamappify/data/criteria/sequel/save_by_key.rb +0 -1
- data/lib/datamappify/data/criteria/sequel/where.rb +18 -0
- data/lib/datamappify/data/errors.rb +8 -9
- data/lib/datamappify/data/mapper/attribute.rb +13 -33
- data/lib/datamappify/data/mapper.rb +13 -2
- data/lib/datamappify/data/provider/active_record.rb +8 -6
- data/lib/datamappify/data/provider/common_provider.rb +2 -2
- data/lib/datamappify/data/provider/sequel.rb +9 -6
- data/lib/datamappify/entity/association/reference.rb +63 -0
- data/lib/datamappify/entity/association/validation.rb +59 -0
- data/lib/datamappify/entity/association.rb +44 -0
- data/lib/datamappify/entity/{active_model/compatibility.rb → compatibility/active_model.rb} +2 -2
- data/lib/datamappify/entity/compatibility/active_record.rb +22 -0
- data/lib/datamappify/entity/compatibility/association/active_record.rb +43 -0
- data/lib/datamappify/entity/composable/attributes.rb +8 -16
- data/lib/datamappify/entity.rb +8 -6
- data/lib/datamappify/lazy/attributes_handler.rb +1 -1
- data/lib/datamappify/lazy.rb +0 -1
- data/lib/datamappify/repository/mapping_dsl.rb +9 -0
- data/lib/datamappify/repository/query_method/criteria.rb +21 -0
- data/lib/datamappify/repository/query_method/destroy.rb +1 -1
- data/lib/datamappify/repository/query_method/exists.rb +1 -1
- data/lib/datamappify/repository/query_method/find.rb +1 -9
- data/lib/datamappify/repository/query_method/method/multi_result_blender.rb +24 -0
- data/lib/datamappify/repository/query_method/method/reference_handler.rb +60 -0
- data/lib/datamappify/repository/query_method/method/source_attributes_walker.rb +19 -4
- data/lib/datamappify/repository/query_method/method.rb +58 -17
- data/lib/datamappify/repository/query_method/save.rb +4 -4
- data/lib/datamappify/repository/query_method/where_or_match.rb +24 -0
- data/lib/datamappify/repository/query_methods.rb +21 -5
- data/lib/datamappify/repository/unit_of_work/persistent_states/object.rb +2 -2
- data/lib/datamappify/version.rb +1 -1
- data/spec/entity/{relation_spec.rb → association/reference_spec.rb} +2 -2
- data/spec/repository/associations/has_many_spec.rb +259 -0
- data/spec/repository/dirty_tracking_spec.rb +68 -57
- data/spec/repository/finders/all_spec.rb +29 -0
- data/spec/repository/finders/criteria_spec.rb +61 -0
- data/spec/repository/finders/different_providers_spec.rb +81 -0
- data/spec/repository/finders/find_spec.rb +21 -0
- data/spec/repository/finders/match_spec.rb +28 -0
- data/spec/repository/finders/where_spec.rb +18 -0
- data/spec/repository/reverse_mapped_spec.rb +20 -4
- data/spec/support/entities/group.rb +4 -0
- data/spec/support/entities/super_user.rb +9 -0
- data/spec/support/entities/user.rb +5 -0
- data/spec/support/entities/user_info.rb +5 -0
- data/spec/support/repositories/active_record/group_repository.rb +4 -0
- data/spec/support/repositories/active_record/super_user_repository.rb +23 -0
- data/spec/support/repositories/active_record/user_repository.rb +6 -4
- data/spec/support/repositories/sequel/group_repository.rb +4 -0
- data/spec/support/repositories/sequel/super_user_repository.rb +23 -0
- data/spec/support/repositories/sequel/user_repository.rb +6 -4
- data/spec/support/shared/contexts.rb +8 -1
- data/spec/support/shared/examples/repository/finders/where_or_match.rb +130 -0
- data/spec/support/tables/active_record.rb +20 -10
- data/spec/support/tables/sequel.rb +20 -7
- data/spec/unit/entity/{relation_spec.rb → association/reference_spec.rb} +5 -5
- data/spec/unit/repository/query_method_spec.rb +9 -2
- metadata +74 -42
- data/lib/datamappify/data/criteria/active_record/find_multiple.rb +0 -40
- data/lib/datamappify/data/criteria/relational/find.rb +0 -25
- data/lib/datamappify/data/criteria/relational/find_by_key.rb +0 -18
- data/lib/datamappify/data/criteria/sequel/find_multiple.rb +0 -43
- data/lib/datamappify/entity/relation.rb +0 -61
- data/lib/datamappify/repository/query_method/find_multiple.rb +0 -28
- data/spec/repository/finders_spec.rb +0 -211
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: datamappify
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.70.0.beta1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Fred Wu
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-
|
|
11
|
+
date: 2013-09-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: virtus
|
|
@@ -16,8 +16,8 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - '>='
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 1.0.0.
|
|
20
|
-
- -
|
|
19
|
+
version: 1.0.0.beta6
|
|
20
|
+
- - <
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
22
|
version: '2.0'
|
|
23
23
|
type: :runtime
|
|
@@ -26,30 +26,24 @@ dependencies:
|
|
|
26
26
|
requirements:
|
|
27
27
|
- - '>='
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: 1.0.0.
|
|
30
|
-
- -
|
|
29
|
+
version: 1.0.0.beta6
|
|
30
|
+
- - <
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
32
|
version: '2.0'
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: activemodel
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
|
-
- -
|
|
38
|
-
- !ruby/object:Gem::Version
|
|
39
|
-
version: 4.0.0.rc1
|
|
40
|
-
- - <
|
|
37
|
+
- - ~>
|
|
41
38
|
- !ruby/object:Gem::Version
|
|
42
|
-
version:
|
|
39
|
+
version: 4.0.0
|
|
43
40
|
type: :runtime
|
|
44
41
|
prerelease: false
|
|
45
42
|
version_requirements: !ruby/object:Gem::Requirement
|
|
46
43
|
requirements:
|
|
47
|
-
- -
|
|
48
|
-
- !ruby/object:Gem::Version
|
|
49
|
-
version: 4.0.0.rc1
|
|
50
|
-
- - <
|
|
44
|
+
- - ~>
|
|
51
45
|
- !ruby/object:Gem::Version
|
|
52
|
-
version:
|
|
46
|
+
version: 4.0.0
|
|
53
47
|
- !ruby/object:Gem::Dependency
|
|
54
48
|
name: hooks
|
|
55
49
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -222,22 +216,16 @@ dependencies:
|
|
|
222
216
|
name: activerecord
|
|
223
217
|
requirement: !ruby/object:Gem::Requirement
|
|
224
218
|
requirements:
|
|
225
|
-
- -
|
|
226
|
-
- !ruby/object:Gem::Version
|
|
227
|
-
version: 4.0.0.rc1
|
|
228
|
-
- - <
|
|
219
|
+
- - ~>
|
|
229
220
|
- !ruby/object:Gem::Version
|
|
230
|
-
version:
|
|
221
|
+
version: 4.0.0
|
|
231
222
|
type: :development
|
|
232
223
|
prerelease: false
|
|
233
224
|
version_requirements: !ruby/object:Gem::Requirement
|
|
234
225
|
requirements:
|
|
235
|
-
- -
|
|
236
|
-
- !ruby/object:Gem::Version
|
|
237
|
-
version: 4.0.0.rc1
|
|
238
|
-
- - <
|
|
226
|
+
- - ~>
|
|
239
227
|
- !ruby/object:Gem::Version
|
|
240
|
-
version:
|
|
228
|
+
version: 4.0.0
|
|
241
229
|
- !ruby/object:Gem::Dependency
|
|
242
230
|
name: database_cleaner
|
|
243
231
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -274,32 +262,47 @@ files:
|
|
|
274
262
|
- lib/datamappify/data.rb
|
|
275
263
|
- lib/datamappify/data/criteria.rb
|
|
276
264
|
- lib/datamappify/data/criteria/active_record/count.rb
|
|
265
|
+
- lib/datamappify/data/criteria/active_record/criteria.rb
|
|
266
|
+
- lib/datamappify/data/criteria/active_record/criteria_method.rb
|
|
277
267
|
- lib/datamappify/data/criteria/active_record/destroy.rb
|
|
278
268
|
- lib/datamappify/data/criteria/active_record/exists.rb
|
|
279
269
|
- lib/datamappify/data/criteria/active_record/find.rb
|
|
280
270
|
- lib/datamappify/data/criteria/active_record/find_by_key.rb
|
|
281
|
-
- lib/datamappify/data/criteria/active_record/
|
|
271
|
+
- lib/datamappify/data/criteria/active_record/limit.rb
|
|
272
|
+
- lib/datamappify/data/criteria/active_record/match.rb
|
|
273
|
+
- lib/datamappify/data/criteria/active_record/order.rb
|
|
274
|
+
- lib/datamappify/data/criteria/active_record/rollback.rb
|
|
282
275
|
- lib/datamappify/data/criteria/active_record/save.rb
|
|
283
276
|
- lib/datamappify/data/criteria/active_record/save_by_key.rb
|
|
284
277
|
- lib/datamappify/data/criteria/active_record/transaction.rb
|
|
278
|
+
- lib/datamappify/data/criteria/active_record/where.rb
|
|
285
279
|
- lib/datamappify/data/criteria/common.rb
|
|
286
280
|
- lib/datamappify/data/criteria/concerns/update_primary_record.rb
|
|
281
|
+
- lib/datamappify/data/criteria/relational/concerns/find.rb
|
|
282
|
+
- lib/datamappify/data/criteria/relational/concerns/find_by_key.rb
|
|
287
283
|
- lib/datamappify/data/criteria/relational/concerns/set_criteria.rb
|
|
288
284
|
- lib/datamappify/data/criteria/relational/count.rb
|
|
289
|
-
- lib/datamappify/data/criteria/relational/
|
|
290
|
-
- lib/datamappify/data/criteria/relational/
|
|
291
|
-
- lib/datamappify/data/criteria/relational/
|
|
285
|
+
- lib/datamappify/data/criteria/relational/criteria.rb
|
|
286
|
+
- lib/datamappify/data/criteria/relational/criteria_base_method.rb
|
|
287
|
+
- lib/datamappify/data/criteria/relational/criteria_method.rb
|
|
288
|
+
- lib/datamappify/data/criteria/relational/limit.rb
|
|
292
289
|
- lib/datamappify/data/criteria/relational/save.rb
|
|
293
290
|
- lib/datamappify/data/criteria/relational/save_by_key.rb
|
|
294
291
|
- lib/datamappify/data/criteria/sequel/count.rb
|
|
292
|
+
- lib/datamappify/data/criteria/sequel/criteria.rb
|
|
293
|
+
- lib/datamappify/data/criteria/sequel/criteria_method.rb
|
|
295
294
|
- lib/datamappify/data/criteria/sequel/destroy.rb
|
|
296
295
|
- lib/datamappify/data/criteria/sequel/exists.rb
|
|
297
296
|
- lib/datamappify/data/criteria/sequel/find.rb
|
|
298
297
|
- lib/datamappify/data/criteria/sequel/find_by_key.rb
|
|
299
|
-
- lib/datamappify/data/criteria/sequel/
|
|
298
|
+
- lib/datamappify/data/criteria/sequel/limit.rb
|
|
299
|
+
- lib/datamappify/data/criteria/sequel/match.rb
|
|
300
|
+
- lib/datamappify/data/criteria/sequel/order.rb
|
|
301
|
+
- lib/datamappify/data/criteria/sequel/rollback.rb
|
|
300
302
|
- lib/datamappify/data/criteria/sequel/save.rb
|
|
301
303
|
- lib/datamappify/data/criteria/sequel/save_by_key.rb
|
|
302
304
|
- lib/datamappify/data/criteria/sequel/transaction.rb
|
|
305
|
+
- lib/datamappify/data/criteria/sequel/where.rb
|
|
303
306
|
- lib/datamappify/data/errors.rb
|
|
304
307
|
- lib/datamappify/data/mapper.rb
|
|
305
308
|
- lib/datamappify/data/mapper/attribute.rb
|
|
@@ -309,14 +312,18 @@ files:
|
|
|
309
312
|
- lib/datamappify/data/provider/sequel.rb
|
|
310
313
|
- lib/datamappify/data/record.rb
|
|
311
314
|
- lib/datamappify/entity.rb
|
|
312
|
-
- lib/datamappify/entity/
|
|
315
|
+
- lib/datamappify/entity/association.rb
|
|
316
|
+
- lib/datamappify/entity/association/reference.rb
|
|
317
|
+
- lib/datamappify/entity/association/validation.rb
|
|
318
|
+
- lib/datamappify/entity/compatibility/active_model.rb
|
|
319
|
+
- lib/datamappify/entity/compatibility/active_record.rb
|
|
320
|
+
- lib/datamappify/entity/compatibility/association/active_record.rb
|
|
313
321
|
- lib/datamappify/entity/composable.rb
|
|
314
322
|
- lib/datamappify/entity/composable/attribute.rb
|
|
315
323
|
- lib/datamappify/entity/composable/attributes.rb
|
|
316
324
|
- lib/datamappify/entity/composable/validators.rb
|
|
317
325
|
- lib/datamappify/entity/inspectable.rb
|
|
318
326
|
- lib/datamappify/entity/lazy_checking.rb
|
|
319
|
-
- lib/datamappify/entity/relation.rb
|
|
320
327
|
- lib/datamappify/lazy.rb
|
|
321
328
|
- lib/datamappify/lazy/attributes_handler.rb
|
|
322
329
|
- lib/datamappify/lazy/source_attributes_walker.rb
|
|
@@ -328,14 +335,17 @@ files:
|
|
|
328
335
|
- lib/datamappify/repository/query_method/callbacks.rb
|
|
329
336
|
- lib/datamappify/repository/query_method/count.rb
|
|
330
337
|
- lib/datamappify/repository/query_method/create.rb
|
|
338
|
+
- lib/datamappify/repository/query_method/criteria.rb
|
|
331
339
|
- lib/datamappify/repository/query_method/destroy.rb
|
|
332
340
|
- lib/datamappify/repository/query_method/exists.rb
|
|
333
341
|
- lib/datamappify/repository/query_method/find.rb
|
|
334
|
-
- lib/datamappify/repository/query_method/find_multiple.rb
|
|
335
342
|
- lib/datamappify/repository/query_method/method.rb
|
|
343
|
+
- lib/datamappify/repository/query_method/method/multi_result_blender.rb
|
|
344
|
+
- lib/datamappify/repository/query_method/method/reference_handler.rb
|
|
336
345
|
- lib/datamappify/repository/query_method/method/source_attributes_walker.rb
|
|
337
346
|
- lib/datamappify/repository/query_method/save.rb
|
|
338
347
|
- lib/datamappify/repository/query_method/update.rb
|
|
348
|
+
- lib/datamappify/repository/query_method/where_or_match.rb
|
|
339
349
|
- lib/datamappify/repository/query_methods.rb
|
|
340
350
|
- lib/datamappify/repository/unit_of_work.rb
|
|
341
351
|
- lib/datamappify/repository/unit_of_work/persistent_states.rb
|
|
@@ -343,15 +353,21 @@ files:
|
|
|
343
353
|
- lib/datamappify/repository/unit_of_work/transaction.rb
|
|
344
354
|
- lib/datamappify/version.rb
|
|
345
355
|
- spec/config_spec.rb
|
|
356
|
+
- spec/entity/association/reference_spec.rb
|
|
346
357
|
- spec/entity/composable_spec.rb
|
|
347
358
|
- spec/entity/inheritance_spec.rb
|
|
348
|
-
- spec/entity/relation_spec.rb
|
|
349
359
|
- spec/entity_spec.rb
|
|
350
360
|
- spec/lazy_spec.rb
|
|
361
|
+
- spec/repository/associations/has_many_spec.rb
|
|
351
362
|
- spec/repository/callbacks_spec.rb
|
|
352
363
|
- spec/repository/dirty_persistence_spec.rb
|
|
353
364
|
- spec/repository/dirty_tracking_spec.rb
|
|
354
|
-
- spec/repository/
|
|
365
|
+
- spec/repository/finders/all_spec.rb
|
|
366
|
+
- spec/repository/finders/criteria_spec.rb
|
|
367
|
+
- spec/repository/finders/different_providers_spec.rb
|
|
368
|
+
- spec/repository/finders/find_spec.rb
|
|
369
|
+
- spec/repository/finders/match_spec.rb
|
|
370
|
+
- spec/repository/finders/where_spec.rb
|
|
355
371
|
- spec/repository/namespaced_mapping_spec.rb
|
|
356
372
|
- spec/repository/persistence_spec.rb
|
|
357
373
|
- spec/repository/reverse_mapped_spec.rb
|
|
@@ -369,7 +385,9 @@ files:
|
|
|
369
385
|
- spec/support/entities/reversed/author.rb
|
|
370
386
|
- spec/support/entities/reversed/post.rb
|
|
371
387
|
- spec/support/entities/role.rb
|
|
388
|
+
- spec/support/entities/super_user.rb
|
|
372
389
|
- spec/support/entities/user.rb
|
|
390
|
+
- spec/support/entities/user_info.rb
|
|
373
391
|
- spec/support/monkey_patches/database_cleaner.rb
|
|
374
392
|
- spec/support/repositories/active_record/admin_user_repository.rb
|
|
375
393
|
- spec/support/repositories/active_record/comment_repository.rb
|
|
@@ -378,6 +396,7 @@ files:
|
|
|
378
396
|
- spec/support/repositories/active_record/reversed/author_repository.rb
|
|
379
397
|
- spec/support/repositories/active_record/reversed/post_repository.rb
|
|
380
398
|
- spec/support/repositories/active_record/role_repository.rb
|
|
399
|
+
- spec/support/repositories/active_record/super_user_repository.rb
|
|
381
400
|
- spec/support/repositories/active_record/user_repository.rb
|
|
382
401
|
- spec/support/repositories/callbacks_chaining_repository.rb
|
|
383
402
|
- spec/support/repositories/hero_user_repository.rb
|
|
@@ -388,12 +407,14 @@ files:
|
|
|
388
407
|
- spec/support/repositories/sequel/reversed/author_repository.rb
|
|
389
408
|
- spec/support/repositories/sequel/reversed/post_repository.rb
|
|
390
409
|
- spec/support/repositories/sequel/role_repository.rb
|
|
410
|
+
- spec/support/repositories/sequel/super_user_repository.rb
|
|
391
411
|
- spec/support/repositories/sequel/user_repository.rb
|
|
392
412
|
- spec/support/shared/contexts.rb
|
|
413
|
+
- spec/support/shared/examples/repository/finders/where_or_match.rb
|
|
393
414
|
- spec/support/tables/active_record.rb
|
|
394
415
|
- spec/support/tables/sequel.rb
|
|
416
|
+
- spec/unit/entity/association/reference_spec.rb
|
|
395
417
|
- spec/unit/entity/composable_spec.rb
|
|
396
|
-
- spec/unit/entity/relation_spec.rb
|
|
397
418
|
- spec/unit/repository/query_method_spec.rb
|
|
398
419
|
homepage: https://github.com/fredwu/datamappify
|
|
399
420
|
licenses:
|
|
@@ -410,9 +431,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
410
431
|
version: '0'
|
|
411
432
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
412
433
|
requirements:
|
|
413
|
-
- - '
|
|
434
|
+
- - '>'
|
|
414
435
|
- !ruby/object:Gem::Version
|
|
415
|
-
version:
|
|
436
|
+
version: 1.3.1
|
|
416
437
|
requirements: []
|
|
417
438
|
rubyforge_project:
|
|
418
439
|
rubygems_version: 2.0.3
|
|
@@ -422,15 +443,21 @@ summary: Compose, decouple and manage domain logic and data persistence separate
|
|
|
422
443
|
Works particularly great for composing form objects!
|
|
423
444
|
test_files:
|
|
424
445
|
- spec/config_spec.rb
|
|
446
|
+
- spec/entity/association/reference_spec.rb
|
|
425
447
|
- spec/entity/composable_spec.rb
|
|
426
448
|
- spec/entity/inheritance_spec.rb
|
|
427
|
-
- spec/entity/relation_spec.rb
|
|
428
449
|
- spec/entity_spec.rb
|
|
429
450
|
- spec/lazy_spec.rb
|
|
451
|
+
- spec/repository/associations/has_many_spec.rb
|
|
430
452
|
- spec/repository/callbacks_spec.rb
|
|
431
453
|
- spec/repository/dirty_persistence_spec.rb
|
|
432
454
|
- spec/repository/dirty_tracking_spec.rb
|
|
433
|
-
- spec/repository/
|
|
455
|
+
- spec/repository/finders/all_spec.rb
|
|
456
|
+
- spec/repository/finders/criteria_spec.rb
|
|
457
|
+
- spec/repository/finders/different_providers_spec.rb
|
|
458
|
+
- spec/repository/finders/find_spec.rb
|
|
459
|
+
- spec/repository/finders/match_spec.rb
|
|
460
|
+
- spec/repository/finders/where_spec.rb
|
|
434
461
|
- spec/repository/namespaced_mapping_spec.rb
|
|
435
462
|
- spec/repository/persistence_spec.rb
|
|
436
463
|
- spec/repository/reverse_mapped_spec.rb
|
|
@@ -448,7 +475,9 @@ test_files:
|
|
|
448
475
|
- spec/support/entities/reversed/author.rb
|
|
449
476
|
- spec/support/entities/reversed/post.rb
|
|
450
477
|
- spec/support/entities/role.rb
|
|
478
|
+
- spec/support/entities/super_user.rb
|
|
451
479
|
- spec/support/entities/user.rb
|
|
480
|
+
- spec/support/entities/user_info.rb
|
|
452
481
|
- spec/support/monkey_patches/database_cleaner.rb
|
|
453
482
|
- spec/support/repositories/active_record/admin_user_repository.rb
|
|
454
483
|
- spec/support/repositories/active_record/comment_repository.rb
|
|
@@ -457,6 +486,7 @@ test_files:
|
|
|
457
486
|
- spec/support/repositories/active_record/reversed/author_repository.rb
|
|
458
487
|
- spec/support/repositories/active_record/reversed/post_repository.rb
|
|
459
488
|
- spec/support/repositories/active_record/role_repository.rb
|
|
489
|
+
- spec/support/repositories/active_record/super_user_repository.rb
|
|
460
490
|
- spec/support/repositories/active_record/user_repository.rb
|
|
461
491
|
- spec/support/repositories/callbacks_chaining_repository.rb
|
|
462
492
|
- spec/support/repositories/hero_user_repository.rb
|
|
@@ -467,11 +497,13 @@ test_files:
|
|
|
467
497
|
- spec/support/repositories/sequel/reversed/author_repository.rb
|
|
468
498
|
- spec/support/repositories/sequel/reversed/post_repository.rb
|
|
469
499
|
- spec/support/repositories/sequel/role_repository.rb
|
|
500
|
+
- spec/support/repositories/sequel/super_user_repository.rb
|
|
470
501
|
- spec/support/repositories/sequel/user_repository.rb
|
|
471
502
|
- spec/support/shared/contexts.rb
|
|
503
|
+
- spec/support/shared/examples/repository/finders/where_or_match.rb
|
|
472
504
|
- spec/support/tables/active_record.rb
|
|
473
505
|
- spec/support/tables/sequel.rb
|
|
506
|
+
- spec/unit/entity/association/reference_spec.rb
|
|
474
507
|
- spec/unit/entity/composable_spec.rb
|
|
475
|
-
- spec/unit/entity/relation_spec.rb
|
|
476
508
|
- spec/unit/repository/query_method_spec.rb
|
|
477
509
|
has_rdoc:
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
require 'datamappify/data/criteria/relational/find_multiple'
|
|
2
|
-
|
|
3
|
-
module Datamappify
|
|
4
|
-
module Data
|
|
5
|
-
module Criteria
|
|
6
|
-
module ActiveRecord
|
|
7
|
-
class FindMultiple < Relational::FindMultiple
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
# @return [Array]
|
|
11
|
-
def records
|
|
12
|
-
source_class.joins(@secondaries.map(&:source_key)).where(
|
|
13
|
-
structured_criteria(primaries, secondaries)
|
|
14
|
-
)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# @param primaries [Array<Attribute>]
|
|
18
|
-
#
|
|
19
|
-
# @param secondaries [Array<Attribute>]
|
|
20
|
-
#
|
|
21
|
-
# @return [Hash]
|
|
22
|
-
def structured_criteria(primaries, secondaries)
|
|
23
|
-
_criteria = {}
|
|
24
|
-
|
|
25
|
-
primaries.each do |primary|
|
|
26
|
-
_criteria[primary.source_attribute_key] = primary.value
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
secondaries.each do |secondary|
|
|
30
|
-
_criteria[secondary.source_table] ||= {}
|
|
31
|
-
_criteria[secondary.source_table][secondary.source_attribute_key] = secondary.value
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
_criteria
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module Datamappify
|
|
2
|
-
module Data
|
|
3
|
-
module Criteria
|
|
4
|
-
module Relational
|
|
5
|
-
class Find < Common
|
|
6
|
-
def perform
|
|
7
|
-
record = source_class.where(criteria).first
|
|
8
|
-
|
|
9
|
-
update_entity_with(record) if record
|
|
10
|
-
|
|
11
|
-
record
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
def update_entity_with(record)
|
|
17
|
-
attributes.each do |attribute|
|
|
18
|
-
entity.send("#{attribute.name}=", record.send(attribute.source_attribute_name))
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
require 'datamappify/data/criteria/relational/find'
|
|
2
|
-
require 'datamappify/data/criteria/relational/concerns/set_criteria'
|
|
3
|
-
|
|
4
|
-
module Datamappify
|
|
5
|
-
module Data
|
|
6
|
-
module Criteria
|
|
7
|
-
module Relational
|
|
8
|
-
class FindByKey < Find
|
|
9
|
-
include Concerns::SetCriteria
|
|
10
|
-
|
|
11
|
-
def initialize(source_class, entity, attributes, options = {}, &block)
|
|
12
|
-
super(source_class, entity, nil, attributes, options, &block)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
require 'datamappify/data/criteria/relational/find_multiple'
|
|
2
|
-
|
|
3
|
-
module Datamappify
|
|
4
|
-
module Data
|
|
5
|
-
module Criteria
|
|
6
|
-
module Sequel
|
|
7
|
-
class FindMultiple < Relational::FindMultiple
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
# @return [Array]
|
|
11
|
-
def records
|
|
12
|
-
query_builder = source_class
|
|
13
|
-
|
|
14
|
-
secondaries.each do |secondary|
|
|
15
|
-
query_builder = query_builder.join(secondary.source_table, secondary.primary_reference_key => :id)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
query_builder.where(structured_criteria(primaries, secondaries))
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# @param primaries [Array<Attribute>]
|
|
22
|
-
#
|
|
23
|
-
# @param secondaries [Array<Attribute>]
|
|
24
|
-
#
|
|
25
|
-
# @return [Hash]
|
|
26
|
-
def structured_criteria(primaries, secondaries)
|
|
27
|
-
_criteria = {}
|
|
28
|
-
|
|
29
|
-
primaries.each do |primary|
|
|
30
|
-
_criteria[primary.source_attribute_key] = primary.value
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
secondaries.each do |secondary|
|
|
34
|
-
_criteria[:"#{secondary.source_table}__#{secondary.source_attribute_name}"] = secondary.value
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
_criteria
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
module Datamappify
|
|
2
|
-
module Entity
|
|
3
|
-
module Relation
|
|
4
|
-
def self.included(klass)
|
|
5
|
-
klass.class_eval do
|
|
6
|
-
cattr_accessor :reference_keys
|
|
7
|
-
extend DSL
|
|
8
|
-
|
|
9
|
-
self.reference_keys = []
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
module DSL
|
|
14
|
-
# @param entity_name [Symbol, String]
|
|
15
|
-
#
|
|
16
|
-
# @return [void]
|
|
17
|
-
def references(entity_name)
|
|
18
|
-
attribute_name = :"#{entity_name}_id"
|
|
19
|
-
|
|
20
|
-
create_attribute attribute_name, Integer
|
|
21
|
-
create_accessor entity_name
|
|
22
|
-
record_attribute attribute_name
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
# @param entity_name (see #references)
|
|
28
|
-
#
|
|
29
|
-
# @return [void]
|
|
30
|
-
def create_accessor(entity_name)
|
|
31
|
-
class_eval <<-CODE, __FILE__, __LINE__ + 1
|
|
32
|
-
attr_reader :#{entity_name}
|
|
33
|
-
|
|
34
|
-
def #{entity_name}=(entity)
|
|
35
|
-
@#{entity_name} = entity
|
|
36
|
-
self.#{entity_name}_id = entity.nil? ? nil : entity.id
|
|
37
|
-
end
|
|
38
|
-
CODE
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# @param name [Symbol]
|
|
42
|
-
#
|
|
43
|
-
# @param type [Class]
|
|
44
|
-
#
|
|
45
|
-
# @param options [any]
|
|
46
|
-
#
|
|
47
|
-
# @return [void]
|
|
48
|
-
def create_attribute(name, type, *args)
|
|
49
|
-
attribute name, type, *args
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
# @param attribute_name [Symbol]
|
|
53
|
-
#
|
|
54
|
-
# @return [Array]
|
|
55
|
-
def record_attribute(attribute_name)
|
|
56
|
-
self.reference_keys << attribute_name
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
module Datamappify
|
|
2
|
-
module Repository
|
|
3
|
-
module QueryMethod
|
|
4
|
-
class FindMultiple < Method
|
|
5
|
-
# @param options (see Method#initialize)
|
|
6
|
-
#
|
|
7
|
-
# @param where [Hash]
|
|
8
|
-
# a hash containing all the find criterias
|
|
9
|
-
def initialize(options, criteria)
|
|
10
|
-
super
|
|
11
|
-
@criteria = criteria
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
# @return [Array<Entity>]
|
|
15
|
-
def perform
|
|
16
|
-
dispatch_criteria_to_default_source(
|
|
17
|
-
:FindMultiple, data_mapper.entity_class, @criteria, data_mapper.attributes
|
|
18
|
-
)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# @see Method#reader?
|
|
22
|
-
def reader?
|
|
23
|
-
true
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|