ydbd-pg 0.5.3 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
data/lib/dbd/Pg.rb CHANGED
@@ -49,7 +49,7 @@ module DBI
49
49
  # Only things that extend DBI's results are documented.
50
50
  #
51
51
  module Pg
52
- VERSION = "0.5.3"
52
+ VERSION = DBI::VERSION
53
53
  DESCRIPTION = "PostgreSQL DBI DBD"
54
54
 
55
55
  #
@@ -46,9 +46,10 @@ class DBI::DBD::Pg::Database < DBI::BaseDatabase
46
46
 
47
47
  hash['options'] ||= nil
48
48
  hash['tty'] ||= ''
49
+ hash['host'] ||= 'localhost'
49
50
  hash['port'] = hash['port'].to_i unless hash['port'].nil?
50
51
 
51
- @connection = PGconn.new(hash['host'], hash['port'], hash['options'], hash['tty'],
52
+ @connection = PG::Connection.new(hash['host'], hash['port'], hash['options'], hash['tty'],
52
53
  hash['dbname'] || hash['database'], user, auth)
53
54
 
54
55
  @exec_method = :exec
@@ -78,7 +79,7 @@ class DBI::DBD::Pg::Database < DBI::BaseDatabase
78
79
 
79
80
  self['AutoCommit'] = true # Postgres starts in unchained mode (AutoCommit=on) by default
80
81
 
81
- rescue PGError => err
82
+ rescue PG::Error => err
82
83
  raise DBI::OperationalError.new(err.message)
83
84
  end
84
85
 
@@ -96,7 +97,7 @@ class DBI::DBD::Pg::Database < DBI::BaseDatabase
96
97
  else
97
98
  return false
98
99
  end
99
- rescue PGError
100
+ rescue PG::Error
100
101
  return false
101
102
  ensure
102
103
  answer.clear if answer
@@ -320,19 +321,6 @@ class DBI::DBD::Pg::Database < DBI::BaseDatabase
320
321
 
321
322
  private
322
323
 
323
- # special quoting if value is element of an array
324
- def quote_array_elements( value )
325
- # XXX is this method still being used?
326
- case value
327
- when Array
328
- '{'+ value.collect{|v| quote_array_elements(v) }.join(',') + '}'
329
- when String
330
- '"' + value.gsub(/\\/){ '\\\\' }.gsub(/"/){ '\\"' } + '"'
331
- else
332
- quote( value ).sub(/^'/,'').sub(/'$/,'')
333
- end
334
- end
335
-
336
324
  def parse_type_name(type_name)
337
325
  case type_name
338
326
  when 'bool' then DBI::Type::Boolean
@@ -397,7 +385,7 @@ class DBI::DBD::Pg::Database < DBI::BaseDatabase
397
385
  # punt
398
386
  @type_map[key] = DBI::DBD::Pg::Type::Array.new(DBI::Type::Varchar)
399
387
  end
400
- end
388
+ end unless key.is_a?(Integer)
401
389
  end
402
390
  end
403
391
 
@@ -426,7 +414,7 @@ class DBI::DBD::Pg::Database < DBI::BaseDatabase
426
414
  def __blob_import(file)
427
415
  start_transaction unless @in_transaction
428
416
  @connection.lo_import(file)
429
- rescue PGError => err
417
+ rescue PG::Error => err
430
418
  raise DBI::DatabaseError.new(err.message)
431
419
  end
432
420
 
@@ -436,27 +424,27 @@ class DBI::DBD::Pg::Database < DBI::BaseDatabase
436
424
  def __blob_export(oid, file)
437
425
  start_transaction unless @in_transaction
438
426
  @connection.lo_export(oid.to_i, file)
439
- rescue PGError => err
427
+ rescue PG::Error => err
440
428
  raise DBI::DatabaseError.new(err.message)
441
429
  end
442
430
 
443
431
  #
444
432
  # Create a BLOB.
445
433
  #
446
- def __blob_create(mode=PGconn::INV_READ)
434
+ def __blob_create(mode=PG::Connection::INV_READ)
447
435
  start_transaction unless @in_transaction
448
436
  @connection.lo_creat(mode)
449
- rescue PGError => err
437
+ rescue PG::Error => err
450
438
  raise DBI::DatabaseError.new(err.message)
451
439
  end
452
440
 
453
441
  #
454
442
  # Open a BLOB.
455
443
  #
456
- def __blob_open(oid, mode=PGconn::INV_READ)
444
+ def __blob_open(oid, mode=PG::Connection::INV_READ)
457
445
  start_transaction unless @in_transaction
458
446
  @connection.lo_open(oid.to_i, mode)
459
- rescue PGError => err
447
+ rescue PG::Error => err
460
448
  raise DBI::DatabaseError.new(err.message)
461
449
  end
462
450
 
@@ -466,7 +454,7 @@ class DBI::DBD::Pg::Database < DBI::BaseDatabase
466
454
  def __blob_unlink(oid)
467
455
  start_transaction unless @in_transaction
468
456
  @connection.lo_unlink(oid.to_i)
469
- rescue PGError => err
457
+ rescue PG::Error => err
470
458
  raise DBI::DatabaseError.new(err.message)
471
459
  end
472
460
 
@@ -474,7 +462,7 @@ class DBI::DBD::Pg::Database < DBI::BaseDatabase
474
462
  # Read a BLOB and return the data.
475
463
  #
476
464
  def __blob_read(oid, length)
477
- blob = @connection.lo_open(oid.to_i, PGconn::INV_READ)
465
+ blob = @connection.lo_open(oid.to_i, PG::Connection::INV_READ)
478
466
 
479
467
  if length.nil?
480
468
  data = @connection.lo_read(blob)
@@ -485,7 +473,7 @@ class DBI::DBD::Pg::Database < DBI::BaseDatabase
485
473
  # FIXME it doesn't like to close here either.
486
474
  # @connection.lo_close(blob)
487
475
  data
488
- rescue PGError => err
476
+ rescue PG::Error => err
489
477
  raise DBI::DatabaseError.new(err.message)
490
478
  end
491
479
 
@@ -494,14 +482,14 @@ class DBI::DBD::Pg::Database < DBI::BaseDatabase
494
482
  #
495
483
  def __blob_write(oid, value)
496
484
  start_transaction unless @in_transaction
497
- blob = @connection.lo_open(oid.to_i, PGconn::INV_WRITE)
485
+ blob = @connection.lo_open(oid.to_i, PG::Connection::INV_WRITE)
498
486
  res = @connection.lo_write(blob, value)
499
487
  # FIXME not sure why PG doesn't like to close here -- seems to be
500
488
  # working but we should make sure it's not eating file descriptors
501
489
  # up before release.
502
490
  # @connection.lo_close(blob)
503
491
  return res
504
- rescue PGError => err
492
+ rescue PG::Error => err
505
493
  raise DBI::DatabaseError.new(err.message)
506
494
  end
507
495
 
@@ -510,7 +498,7 @@ class DBI::DBD::Pg::Database < DBI::BaseDatabase
510
498
  #
511
499
  def __set_notice_processor(proc)
512
500
  @connection.set_notice_processor proc
513
- rescue PGError => err
501
+ rescue PG::Error => err
514
502
  raise DBI::DatabaseError.new(err.message)
515
503
  end
516
504
  end # Database
@@ -18,7 +18,7 @@ class DBI::DBD::Pg::Statement < DBI::BaseStatement
18
18
  @result = nil
19
19
  @bindvars = []
20
20
  @prepared = false
21
- rescue PGError => err
21
+ rescue PG::Error => err
22
22
  raise DBI::ProgrammingError.new(err.message)
23
23
  end
24
24
 
@@ -36,7 +36,7 @@ class DBI::DBD::Pg::Statement < DBI::BaseStatement
36
36
  # replace DBI::Binary object by oid returned by lo_import
37
37
  @bindvars.collect! do |var|
38
38
  if var.is_a? DBI::Binary then
39
- oid = @db.__blob_create(PGconn::INV_WRITE)
39
+ oid = @db.__blob_create(PG::Connection::INV_WRITE)
40
40
  @db.__blob_write(oid, var.to_s)
41
41
  oid
42
42
  else
@@ -58,7 +58,7 @@ class DBI::DBD::Pg::Statement < DBI::BaseStatement
58
58
  end
59
59
 
60
60
  @result = DBI::DBD::Pg::Tuples.new(@db, pg_result)
61
- rescue PGError, RuntimeError => err
61
+ rescue PG::Error, RuntimeError => err
62
62
  raise DBI::ProgrammingError.new(err.message)
63
63
  end
64
64
 
data/lib/dbd/pg/type.rb CHANGED
@@ -32,7 +32,7 @@ module DBI::DBD::Pg::Type
32
32
  # Escapes the supplied data. Has no effect on the object.
33
33
  #
34
34
  def escape_bytea(str)
35
- PGconn.escape_bytea(str)
35
+ PG::Connection.escape_bytea(str)
36
36
  end
37
37
 
38
38
  #
@@ -62,7 +62,7 @@ module DBI::DBD::Pg::Type
62
62
  #
63
63
  # Fix this for now, but beware that we'll have to unfix this as
64
64
  # soon as they fix their end.
65
- ret = PGconn.unescape_bytea(obj)
65
+ ret = PG::Connection.unescape_bytea(obj)
66
66
 
67
67
  # XXX
68
68
  # String#split does not properly create a full array if the the
data/readme.md CHANGED
@@ -1,3 +1,10 @@
1
+ # Release a new ydbi gem
2
+
3
+ * bundle exec rake test test_dbd test_dbi
4
+ * rake ydbd-pg:clobber_package; rake ydbd-pg:clobber_package; rake ydbi:gem ydbd-pg:gem
5
+ * bundle exec gem push pkg/ydbd-*.gem
6
+ * bundle exec gem push pkg/ydbi-*.gem
7
+
1
8
  # Description
2
9
  The DBI package is a vendor independent interface for accessing databases.
3
10
  It is similar, but not identical to, Perl's DBI module.
@@ -75,6 +82,15 @@
75
82
  gem install dbd-sqlite3
76
83
  gem install dbd-sqlite
77
84
 
85
+ If you have a non standard path of postgres use something like
86
+
87
+ gem install pg -- --with-pg-config=/usr/local/pgsql-10.1/bin/pg_config
88
+
89
+ Or if you are using bundler
90
+
91
+ bundle config build.pg --with-pg-config=/usr/local/pgsql-10.1/bin/pg_config
92
+ bundle install
93
+
78
94
  ## Without rubygems:
79
95
 
80
96
  ruby setup.rb config
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ydbd-pg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Hollensbe
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-01 00:00:00.000000000 Z
12
+ date: 2021-03-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ydbi
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 0.5.0
20
+ version: 0.5.8
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ">="
25
+ - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 0.5.0
27
+ version: 0.5.8
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: pg
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -74,7 +74,8 @@ files:
74
74
  - test/dbd/postgresql/up.sql
75
75
  - test/ts_dbd.rb
76
76
  homepage: https://github.com/zdavatz/ydbi
77
- licenses: []
77
+ licenses:
78
+ - MIT
78
79
  metadata: {}
79
80
  post_install_message:
80
81
  rdoc_options: []
@@ -91,10 +92,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
92
  - !ruby/object:Gem::Version
92
93
  version: '0'
93
94
  requirements: []
94
- rubyforge_project: ydbi
95
- rubygems_version: 2.4.5
95
+ rubygems_version: 3.2.4
96
96
  signing_key:
97
97
  specification_version: 4
98
- summary: PostgreSQL DBI DBD
98
+ summary: PostgreSQL DBI DBD ywesee fork
99
99
  test_files:
100
100
  - test/ts_dbd.rb