rom-sql 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,6 +16,10 @@ RSpec.describe ROM::Relation, '#by_pk' do
16
16
  it 'qualifies pk attr' do
17
17
  expect(relation.qualified.by_pk(1).select(:id).join(:tasks, user_id: :id).one).to eql(id: 1)
18
18
  end
19
+
20
+ it 'works even when PK is not projected' do
21
+ expect(relation.select(:name).by_pk(1).to_a).to eql([name: 'Jane'])
22
+ end
19
23
  end
20
24
 
21
25
  context 'with a composite PK' do
@@ -24,6 +28,10 @@ RSpec.describe ROM::Relation, '#by_pk' do
24
28
  it 'restricts a relation by is PK' do
25
29
  expect(relation.by_pk(1, 1).to_a).to eql([{ tag_id: 1, task_id: 1 }])
26
30
  end
31
+
32
+ it 'works even when PK is not projected' do
33
+ expect(relation.by_pk(1, 1).select { `1`.as(:num) }.to_a).to eql([num: 1])
34
+ end
27
35
  end
28
36
 
29
37
  context 'without PK' do
@@ -0,0 +1,25 @@
1
+ RSpec.describe ROM::Relation, '#exist?' do
2
+ include_context 'users and tasks'
3
+
4
+ subject(:relation) { users }
5
+
6
+ with_adapters do
7
+ it 'returns true if relation has at least one tuple' do
8
+ expect(relation.exist?).to be(true)
9
+ end
10
+
11
+ it 'returns false if relation is empty' do
12
+ expect(relation.where(name: 'Klaus').exist?).to be(false)
13
+ end
14
+
15
+ it 'accepts a condition' do
16
+ expect(relation.exist?(name: 'Jane')).to be(true)
17
+ expect(relation.exist?(name: 'Klaus')).to be(false)
18
+ end
19
+
20
+ it 'accepts a block' do
21
+ expect(relation.exist? { name.is('Jane') }).to be true
22
+ expect(relation.exist? { name.is('Klaus') }).to be false
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rom-sql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-25 00:00:00.000000000 Z
11
+ date: 2017-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -44,20 +44,20 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.9'
47
+ version: '0.10'
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: 0.9.4
50
+ version: 0.10.2
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: '0.9'
57
+ version: '0.10'
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: 0.9.4
60
+ version: 0.10.2
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: dry-core
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -85,6 +85,9 @@ dependencies:
85
85
  - - "~>"
86
86
  - !ruby/object:Gem::Version
87
87
  version: '3.2'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 3.2.1
88
91
  type: :runtime
89
92
  prerelease: false
90
93
  version_requirements: !ruby/object:Gem::Requirement
@@ -92,6 +95,9 @@ dependencies:
92
95
  - - "~>"
93
96
  - !ruby/object:Gem::Version
94
97
  version: '3.2'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 3.2.1
95
101
  - !ruby/object:Gem::Dependency
96
102
  name: bundler
97
103
  requirement: !ruby/object:Gem::Requirement
@@ -218,6 +224,7 @@ files:
218
224
  - lib/rom/sql/version.rb
219
225
  - log/.gitkeep
220
226
  - rom-sql.gemspec
227
+ - spec/extensions/postgres/attribute_spec.rb
221
228
  - spec/extensions/postgres/integration_spec.rb
222
229
  - spec/extensions/postgres/types_spec.rb
223
230
  - spec/extensions/sqlite/types_spec.rb
@@ -286,6 +293,7 @@ files:
286
293
  - spec/unit/migration_tasks_spec.rb
287
294
  - spec/unit/migrator_spec.rb
288
295
  - spec/unit/order_dsl_spec.rb
296
+ - spec/unit/plugin/associates_spec.rb
289
297
  - spec/unit/plugin/pagination_spec.rb
290
298
  - spec/unit/plugin/timestamp_spec.rb
291
299
  - spec/unit/projection_dsl_spec.rb
@@ -296,6 +304,7 @@ files:
296
304
  - spec/unit/relation/dataset_spec.rb
297
305
  - spec/unit/relation/distinct_spec.rb
298
306
  - spec/unit/relation/exclude_spec.rb
307
+ - spec/unit/relation/exist_predicate_spec.rb
299
308
  - spec/unit/relation/fetch_spec.rb
300
309
  - spec/unit/relation/group_spec.rb
301
310
  - spec/unit/relation/having_spec.rb
@@ -346,11 +355,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
346
355
  version: '0'
347
356
  requirements: []
348
357
  rubyforge_project:
349
- rubygems_version: 2.6.10
358
+ rubygems_version: 2.6.11
350
359
  signing_key:
351
360
  specification_version: 4
352
361
  summary: SQL databases support for ROM
353
362
  test_files:
363
+ - spec/extensions/postgres/attribute_spec.rb
354
364
  - spec/extensions/postgres/integration_spec.rb
355
365
  - spec/extensions/postgres/types_spec.rb
356
366
  - spec/extensions/sqlite/types_spec.rb
@@ -419,6 +429,7 @@ test_files:
419
429
  - spec/unit/migration_tasks_spec.rb
420
430
  - spec/unit/migrator_spec.rb
421
431
  - spec/unit/order_dsl_spec.rb
432
+ - spec/unit/plugin/associates_spec.rb
422
433
  - spec/unit/plugin/pagination_spec.rb
423
434
  - spec/unit/plugin/timestamp_spec.rb
424
435
  - spec/unit/projection_dsl_spec.rb
@@ -429,6 +440,7 @@ test_files:
429
440
  - spec/unit/relation/dataset_spec.rb
430
441
  - spec/unit/relation/distinct_spec.rb
431
442
  - spec/unit/relation/exclude_spec.rb
443
+ - spec/unit/relation/exist_predicate_spec.rb
432
444
  - spec/unit/relation/fetch_spec.rb
433
445
  - spec/unit/relation/group_spec.rb
434
446
  - spec/unit/relation/having_spec.rb