fluiddb 0.0.19 → 0.0.20

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.
data/lib/FluidDb.rb CHANGED
@@ -18,7 +18,9 @@ module FluidDb
18
18
  end
19
19
  class IncorrectNumberOfParametersError<StandardError
20
20
  end
21
-
21
+ class DuplicateKeyError<StandardError
22
+ end
23
+
22
24
  class Base
23
25
 
24
26
  attr_writer :verbose
@@ -45,7 +47,7 @@ module FluidDb
45
47
  if params.length != sql.count( "?" ) then
46
48
  raise IncorrectNumberOfParametersError.new
47
49
  end
48
-
50
+
49
51
  sql_out = ""
50
52
  sql.split( "?" ).each_with_index do |s,idx|
51
53
  sql_out = sql_out + s
data/lib/FluidDb/Pgsql.rb CHANGED
@@ -96,6 +96,10 @@ module FluidDb
96
96
  r.cmd_tuples != expected_affected_rows then
97
97
  raise ExpectedAffectedRowsError.new( "Expected affected rows, #{expected_affected_rows}, Actual affected rows, #{r.cmd_tuples}")
98
98
  end
99
+ rescue PG::Error => e
100
+ raise DuplicateKeyError.new( e.message ) unless e.message.index( "duplicate key value violates unique constraint" ).nil?
101
+
102
+ raise e
99
103
  end
100
104
 
101
105
  def insert( sql, params )
@@ -7,7 +7,7 @@ module FluidDb
7
7
 
8
8
  # Connect to Db.
9
9
  #
10
- # @param [String] uri a location for the resource to which we will attach, eg tinytds://user:pass@127.0.0.1
10
+ # @param [String] uri a location for the resource to which we will attach, eg tinytds://<user>:<pass>@<dataserver>/<database>
11
11
  def connect()
12
12
  uri = @uri
13
13
 
@@ -16,6 +16,18 @@ module FluidDb
16
16
  username = URI.unescape( uri.user )
17
17
  password = uri.password
18
18
 
19
+
20
+ if dataserver == "" ||
21
+ database == "" then
22
+ raise "*** You need to specify both a dataserver and a database for the tinytds driver. Expected format: tinytds://<user>:<pass>@<dataserver>/<database>\n" +
23
+ "*** The specified dataserver should have an entry in /etc/freetds/freetds.conf"
24
+ end
25
+
26
+ if username == "" ||
27
+ password == "" then
28
+ puts "*** Warning - you will normally need to specify both a username and password for the tinytds driver to work correctly."
29
+ end
30
+
19
31
  @connection = ::TinyTds::Client.new( :username => username, :password => password, :database => database, :dataserver => dataserver )
20
32
  end
21
33
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluiddb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.20
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-26 00:00:00.000000000 Z
12
+ date: 2013-03-27 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A semantic layer for db interaction
15
15
  email: guy@guyirvine.com