orientdb_client 0.0.5 → 0.0.6

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: c3b7e8eed23a652cb9e3b2011164a7327ef5c554
4
- data.tar.gz: 9f567cb1117ad35b8ffbf656f3e1767e0f7dedbb
3
+ metadata.gz: 03bbffcac337c8b24baa097e7f55f3d4350cea44
4
+ data.tar.gz: a2074ddd31091c8aaae2af2fb49f2d94633d370d
5
5
  SHA512:
6
- metadata.gz: fc6cd1274f0452ea61b90bee9ddfcf4c8a6aa65f80ca408820074310e658ba0b3e51d3b5a861829c24aaf150c1bc442868ee5eb031129436af90cc32da56ed1e
7
- data.tar.gz: 9923fe4d47c09552ae309c82cf0bc90bdcb501d0cbd41dfe7ce1ad51fd0966e64434ef4a52053e2346b0e1408bf1a84a873d963dcd12b7e73833013a21842fdf
6
+ metadata.gz: a4191890669fe5a9fe9ff44e986b355adaf9a4c7182783e9d47df3ce9f4ec64d2f4f91a8050544b5509b16d4166a92a9c1cbf7a46af6fbc13103d3a2a03cce8c
7
+ data.tar.gz: 896fc166ca48be6faef0729eb14cd4fda54a894460d3270b78389e0a480dcd129b6d06b3c00cb3216c42449b671599aeeef8920bf973eafa06b4d5c5308b29f7
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Master
4
4
 
5
+ ## 0.0.6
6
+
7
+ * Correctly handle error message for database creation conflict exceptions.
8
+ * Ensure `NegativeArraySizeException`s are correctly converted to `NotFoundError`s across all supported versions of Orientdb.
9
+ * Ensure "database already exists" errors messages are consistent across all supported versions of Orientdb.
10
+
5
11
  ## 0.0.5
6
12
 
7
13
  * Differentiate between Typhoeus adapter timeouts and connection failures.
data/README.md CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/lukeasrodgers/orientdb_client.svg)](https://travis-ci.org/lukeasrodgers/orientdb_client)
4
4
 
5
- Ruby client for Orientdb. Probably not quite ready for production yet.
5
+ While not yet at version 1.0, the client has been in use in a production environment for several months, working fine, with some minor improvements and bugfixes along the way.
6
+
6
7
  Inspired by https://github.com/veny/orientdb4r
7
8
 
8
9
  Goals:
@@ -12,11 +13,13 @@ Goals:
12
13
 
13
14
  Tested on:
14
15
  * 2.1.5
16
+ * 2.1.4
15
17
  * 2.0.6 - specs may fail due to Orientdb bug with deleting database (https://github.com/orientechnologies/orientdb/issues/3746)
16
18
  * 2.0.4
17
19
  * 2.0.2
18
20
 
19
- CI tests with Travis currently only run non-integration tests (i.e. they don't actually hit an Orientdb server).
21
+ CI tests with Travis currently only run non-integration tests (i.e. they don't actually hit an Orientdb server). This means that the "tested on versions x.x.x" is *manual testing*.
22
+ That is to say, this testing process is error-prone, so you should run the tests yourself with whatever version of Orientdb you are using.
20
23
 
21
24
  ## Installation
22
25
 
@@ -1,3 +1,3 @@
1
1
  module OrientdbClient
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -344,14 +344,20 @@ module OrientdbClient
344
344
  when /ODatabaseException/
345
345
  if odb_error_message.match(/already exists/)
346
346
  klass = ConflictError
347
+ message = 'Database already exists'
347
348
  else
348
349
  klass = ServerError
350
+ message = "#{odb_error_class}: #{odb_error_message}"
349
351
  end
350
- raise klass.new("#{odb_error_class}: #{odb_error_message}", code, body)
352
+ raise klass.new(message, code, body)
351
353
  when /ODistributedRecordLockedException/
352
354
  raise DistributedRecordLockedException.new("#{odb_error_class}: #{odb_error_message}", code, body)
353
355
  when /OSerializationException/
354
356
  raise SerializationException.new("#{odb_error_class}: #{odb_error_message}", code, body)
357
+ when /NegativeArraySizeException/
358
+ raise NegativeArraySizeException.new("#{odb_error_class}: #{odb_error_message}", code, body)
359
+ else
360
+ raise ServerError.new("Unparseable Orientdb server error", code, body)
355
361
  end
356
362
  end
357
363
 
@@ -365,7 +371,7 @@ module OrientdbClient
365
371
  code = response.response_code
366
372
  body = response.body
367
373
  if (body.match(/Database.*already exists/))
368
- raise ConflictError.new(e.message, code, body)
374
+ raise ConflictError.new('Database already exists', code, body)
369
375
  elsif (body.match(/NegativeArraySizeException/))
370
376
  raise NegativeArraySizeException.new(e.message, code, body)
371
377
  else
@@ -379,7 +385,7 @@ module OrientdbClient
379
385
  [matches[1], matches[2]]
380
386
  rescue => e
381
387
  if (response.body.match(/Database.*already exists/))
382
- raise ConflictError.new(e.message, response.response_code, response.body)
388
+ raise ConflictError.new('Database already exists', response.response_code, response.body)
383
389
  elsif (response.body.match(/NegativeArraySizeException/))
384
390
  raise NegativeArraySizeException.new(e.message, response.response_code, response.body)
385
391
  else
@@ -97,13 +97,23 @@ RSpec.describe OrientdbClient do
97
97
  end
98
98
 
99
99
  context 'with existing database' do
100
- it 'creates a database' do
100
+ it 'raises a ConflictError' do
101
101
  client.create_database(temp_db_name, 'plocal', 'document')
102
102
  expect(client.database_exists?(temp_db_name)).to be true
103
103
  expect do
104
104
  client.create_database(temp_db_name, 'plocal', 'document')
105
105
  end.to raise_exception(OrientdbClient::ConflictError)
106
106
  end
107
+
108
+ it 'extracts the right conflict error message' do
109
+ client.create_database(temp_db_name, 'plocal', 'document')
110
+ expect(client.database_exists?(temp_db_name)).to be true
111
+ begin
112
+ client.create_database(temp_db_name, 'plocal', 'document')
113
+ rescue => e
114
+ expect(e.message).to eql('Database already exists')
115
+ end
116
+ end
107
117
  end
108
118
 
109
119
  context 'with invalid storage type' do
@@ -651,6 +661,42 @@ RSpec.describe OrientdbClient do
651
661
  end
652
662
  end
653
663
 
664
+ describe 'handling `NegativeArraySizeException`s' do
665
+ before do
666
+ client.connect(username: username, password: password, db: db)
667
+ if client.has_class?('Person')
668
+ client.command('delete vertex Person')
669
+ client.drop_class('Person')
670
+ end
671
+ if client.has_class?('Friend')
672
+ client.drop_class('Friend')
673
+ end
674
+ end
675
+
676
+ after do
677
+ client.command('delete vertex Person')
678
+ client.drop_class('Person')
679
+ client.drop_class('Friend')
680
+ end
681
+
682
+ it 'translates this exception into a NotFoundError' do
683
+ client.create_class('Person', extends: 'V')
684
+ client.create_class('Friend', extends: 'E')
685
+ client.command('create property Friend.out link Person')
686
+ client.command('create property Friend.in link Person')
687
+ client.command('create index FollowIdx on Friend (out,in) unique')
688
+ client.command('create property Person.user_id integer')
689
+ jim = client.command('insert into Person CONTENT ' + Oj.dump({'name' => 'jim', 'user_id' => 1}))
690
+ bob = client.command('insert into Person CONTENT ' + Oj.dump({'name' => 'bob', 'user_id' => 2}))
691
+ jim_rid = jim['result'][0]['@rid']
692
+ bob_rid = bob['result'][0]['@rid']
693
+ client.command("create edge Friend from #{jim_rid} to #{bob_rid}")
694
+ expect do
695
+ client.query("select in('Friend')[660-669].user_id,user_id from Person where user_id in [2]", {:limit=>1})
696
+ end.to raise_exception(OrientdbClient::NotFoundError)
697
+ end
698
+ end
699
+
654
700
  describe 'duplicate record creation violating index constraint' do
655
701
  before do
656
702
  client.connect(username: username, password: password, db: db)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orientdb_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Rodgers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-13 00:00:00.000000000 Z
11
+ date: 2016-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus