rom-sql 0.3.1 → 0.3.2

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: 17d07fe9555b80ab518029eb126f90e93e8b4c3d
4
- data.tar.gz: 9beb66309d64a2aa65f7c4ab47d57cc274b53085
3
+ metadata.gz: 2e002fcfac65061b46118390214d8731033307b4
4
+ data.tar.gz: a13fd979244aee8b7a2c46ef4b522333534ecbd9
5
5
  SHA512:
6
- metadata.gz: 3d72099961426bc8cd2a60faa7001f0a7b65a353bd5a93e4e12c9a233002c340f7c928ce21df42c14a9e59fdd06a14740f5f477c88a065ad3cd929c6f6a86c73
7
- data.tar.gz: 562af5a84d07462549511657df45cdbc18e4e9904d3a7cd3742c9d1ad846f2e3c6c136873a54da7661940dc6c41feb3e7490da6e03243595e12c01b6ad34de84
6
+ metadata.gz: 27e70cf80b500a17af3d29ec60d10c9066caed57256a39f9f7acdc6955999b68d38b18e0356d2ac0518340280651ef5d08d15fd973753050cd66086e0bed2726
7
+ data.tar.gz: 8b37d7213ff4a0330a3331969886d670a8a09d46dd0cea8145bd45a1959259d44b3fe4dfac5544df6cda76eb0718d6b3406b67d0b7953c90c04c1346ee80bd88
@@ -15,6 +15,7 @@ rvm:
15
15
  matrix:
16
16
  allow_failures:
17
17
  - rvm: ruby-head
18
+ - rvm: jruby
18
19
  notifications:
19
20
  webhooks:
20
21
  urls:
@@ -1,3 +1,11 @@
1
+ ## v0.3.2 2015-01-01
2
+
3
+ ### Fixed
4
+
5
+ * Checking tuple count in commands (solnic)
6
+
7
+ [Compare v0.3.1...v0.3.2](https://github.com/rom-rb/rom-sql/compare/v0.3.1...v0.3.2)
8
+
1
9
  ## v0.3.1 2014-12-31
2
10
 
3
11
  ### Added
@@ -6,7 +6,18 @@ module ROM
6
6
  Sequel::NotNullConstraintViolation
7
7
  ].freeze
8
8
 
9
+ module TupleCount
10
+ # TODO: we need an interface for "target_count" here
11
+ def assert_tuple_count
12
+ if result == :one && target.count > 1
13
+ raise TupleCountMismatchError, "#{inspect} expects one tuple"
14
+ end
15
+ end
16
+ end
17
+
9
18
  class Create < ROM::Commands::Create
19
+ include TupleCount
20
+
10
21
  def execute(tuples)
11
22
  pks = Array([tuples]).flatten.map do |tuple|
12
23
  attributes = input[tuple]
@@ -21,6 +32,8 @@ module ROM
21
32
  end
22
33
 
23
34
  class Update < ROM::Commands::Update
35
+ include TupleCount
36
+
24
37
  def execute(tuple)
25
38
  attributes = input[tuple]
26
39
  validator.call(attributes)
@@ -33,6 +46,8 @@ module ROM
33
46
  end
34
47
 
35
48
  class Delete < ROM::Commands::Delete
49
+ include TupleCount
50
+
36
51
  def execute
37
52
  deleted = target.to_a
38
53
  target.delete
@@ -1,5 +1,5 @@
1
1
  module ROM
2
2
  module SQL
3
- VERSION = "0.3.1".freeze
3
+ VERSION = "0.3.2".freeze
4
4
  end
5
5
  end
@@ -13,22 +13,24 @@ describe 'Commands / Delete' do
13
13
  end
14
14
 
15
15
  setup.commands(:users) do
16
- define(:delete)
16
+ define(:delete) do
17
+ result :one
18
+ end
17
19
  end
18
20
 
19
21
  rom.relations.users.insert(id: 2, name: 'Jane')
20
22
  end
21
23
 
22
- it 'deletes all tuples' do
24
+ it 'raises error when tuple count does not match expectation' do
23
25
  result = users.try { delete }
24
26
 
25
- expect(result.value.to_a)
26
- .to match_array([{ id: 1, name: 'Piotr' }, { id: 2, name: 'Jane' }])
27
+ expect(result.value).to be(nil)
28
+ expect(result.error).to be_instance_of(ROM::TupleCountMismatchError)
27
29
  end
28
30
 
29
31
  it 'deletes all tuples in a restricted relation' do
30
32
  result = users.try { delete(:by_name, 'Jane') }
31
33
 
32
- expect(result.value).to match_array([{ id: 2, name: 'Jane' }])
34
+ expect(result.value).to eql({ id: 2, name: 'Jane' })
33
35
  end
34
36
  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: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-31 00:00:00.000000000 Z
11
+ date: 2015-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel