do_postgres 0.9.12-x86-mingw32 → 0.10.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/lib/do_postgres.rb CHANGED
@@ -1,21 +1,28 @@
1
- require 'rubygems'
2
1
  require 'data_objects'
3
2
  if RUBY_PLATFORM =~ /java/
4
3
  require 'do_jdbc'
5
4
  require 'java'
6
- gem 'jdbc-postgres'
7
- require 'jdbc/postgres' # the JDBC driver, packaged as a gem
8
- end
9
5
 
10
- require 'do_postgres_ext'
11
- require File.expand_path(File.join(File.dirname(__FILE__), 'do_postgres', 'version'))
12
- require File.expand_path(File.join(File.dirname(__FILE__), 'do_postgres', 'transaction'))
6
+ driver = 'org.postgresql.Driver'
7
+ begin
8
+ java.lang.Thread.currentThread.getContextClassLoader().loadClass(driver, true)
9
+ rescue
10
+ require 'jdbc/postgres' # the JDBC driver, packaged as a gem
11
+ end
13
12
 
14
- if RUBY_PLATFORM =~ /java/
15
13
  # Another way of loading the JDBC Class. This seems to be more reliable
16
14
  # than Class.forName() within the data_objects.Connection Java class,
17
15
  # which is currently not working as expected.
18
- import 'org.postgresql.Driver'
16
+ java_import driver
17
+
18
+ end
19
+
20
+ require 'do_postgres_ext'
21
+ require 'do_postgres/version'
22
+ require 'do_postgres/transaction'
23
+ require 'do_postgres/encoding'
24
+
25
+ if RUBY_PLATFORM =~ /java/
19
26
 
20
27
  module DataObjects
21
28
  module Postgres
@@ -23,16 +30,6 @@ if RUBY_PLATFORM =~ /java/
23
30
  def self.pool_size
24
31
  20
25
32
  end
26
-
27
- def character_set
28
- # JDBC API does not provide an easy way to get the current character set
29
- reader = self.create_command("SELECT pg_client_encoding()").execute_reader
30
- reader.next!
31
- char_set = reader.values.to_s
32
- reader.close
33
- char_set.downcase
34
- end
35
-
36
33
  end
37
34
  end
38
35
  end
@@ -0,0 +1,42 @@
1
+ module DataObjects
2
+ module Postgres
3
+ module Encoding
4
+ MAP = {
5
+ "Big5" => "BIG5",
6
+ "GB2312" => "EUC_CN",
7
+ "EUC-JP" => "EUC_JP",
8
+ "EUC-KR" => "EUC_KR",
9
+ "EUC-TW" => "EUC_TW",
10
+ "GB18030" => "GB18030",
11
+ "GBK" => "GBK",
12
+ "ISO-8859-5" => "ISO_8859_5",
13
+ "ISO-8859-6" => "ISO_8859_6",
14
+ "ISO-8859-7" => "ISO_8859_7",
15
+ "ISO-8859-8" => "ISO_8859_8",
16
+ "KOI8-U" => "KOI8",
17
+ "ISO-8859-1" => "LATIN1",
18
+ "ISO-8859-2" => "LATIN2",
19
+ "ISO-8859-3" => "LATIN3",
20
+ "ISO-8859-4" => "LATIN4",
21
+ "ISO-8859-9" => "LATIN5",
22
+ "ISO-8859-10" => "LATIN6",
23
+ "ISO-8859-13" => "LATIN7",
24
+ "ISO-8859-14" => "LATIN8",
25
+ "ISO-8859-15" => "LATIN9",
26
+ "ISO-8859-16" => "LATIN10",
27
+ "Emacs-Mule" => "MULE_INTERNAL",
28
+ "SJIS" => "SJIS",
29
+ "US-ASCII" => "SQL_ASCII",
30
+ "CP949" => "UHC",
31
+ "UTF-8" => "UTF8",
32
+ "IBM866" => "WIN866",
33
+ "Windows-874" => "WIN874",
34
+ "Windows-1250" => "WIN1250",
35
+ "Windows-1251" => "WIN1251",
36
+ "Windows-1252" => "WIN1252",
37
+ "Windows-1256" => "WIN1256",
38
+ "Windows-1258" => "WIN1258"
39
+ }
40
+ end
41
+ end
42
+ end
@@ -10,7 +10,17 @@ module DataObjects
10
10
  connection.create_command(cmd).execute_non_query
11
11
  end
12
12
 
13
+ def begin_prepared
14
+ cmd = "BEGIN"
15
+ connection.create_command(cmd).execute_non_query
16
+ end
17
+
13
18
  def commit
19
+ cmd = "COMMIT"
20
+ connection.create_command(cmd).execute_non_query
21
+ end
22
+
23
+ def commit_prepared
14
24
  cmd = "COMMIT PREPARED '#{id}'"
15
25
  connection.create_command(cmd).execute_non_query
16
26
  end
@@ -1,5 +1,5 @@
1
1
  module DataObjects
2
2
  module Postgres
3
- VERSION = "0.9.12"
3
+ VERSION = "0.10.0"
4
4
  end
5
5
  end
Binary file
@@ -4,5 +4,16 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
4
4
  require 'data_objects/spec/encoding_spec'
5
5
 
6
6
  describe DataObjects::Postgres::Connection do
7
- it_should_behave_like 'a driver supporting encodings'
7
+ unless JRUBY
8
+ # Do NOT test this on JRuby:
9
+ #
10
+ # http://jdbc.postgresql.org/documentation/80/connect.html
11
+ #
12
+ # According to the Postgres documentation, as of Postgres 7.2, multibyte
13
+ # support is enabled by default in the server. The underlying JDBC Driver
14
+ # handles setting the internal client_encoding setting appropriately. It
15
+ # can be overridden -- but for now, we won't support doing this.
16
+ #
17
+ it_should_behave_like 'a driver supporting encodings'
18
+ end
8
19
  end
data/spec/spec_helper.rb CHANGED
@@ -11,21 +11,24 @@ require 'ostruct'
11
11
  require 'pathname'
12
12
  require 'fileutils'
13
13
 
14
+ dir = File.dirname(__FILE__)
15
+ lib_path = File.expand_path("#{dir}/../lib")
16
+ $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
14
17
  # put data_objects from repository in the load path
15
18
  # DO NOT USE installed gem of data_objects!
16
- $:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'data_objects', 'lib'))
17
- require 'data_objects'
18
-
19
- DATAOBJECTS_SPEC_ROOT = Pathname(__FILE__).dirname.parent.parent + 'data_objects' + 'spec'
20
- Pathname.glob((DATAOBJECTS_SPEC_ROOT + 'lib/**/*.rb').to_s).each { |f| require f }
19
+ do_lib_path = File.expand_path("#{dir}/../../data_objects/lib")
20
+ $LOAD_PATH.unshift do_lib_path unless $LOAD_PATH.include?(do_lib_path)
21
21
 
22
22
  if JRUBY
23
- $:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'do_jdbc', 'lib'))
23
+ jdbc_lib_path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'do_jdbc', 'lib'))
24
+ $LOAD_PATH.unshift jdbc_lib_path unless $LOAD_PATH.include?(jdbc_lib_path)
24
25
  require 'do_jdbc'
25
26
  end
26
27
 
27
- # put the pre-compiled extension in the path to be found
28
- $:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
28
+ require 'data_objects'
29
+
30
+ DATAOBJECTS_SPEC_ROOT = Pathname(__FILE__).dirname.parent.parent + 'data_objects' + 'spec'
31
+ Pathname.glob((DATAOBJECTS_SPEC_ROOT + 'lib/**/*.rb').to_s).each { |f| require f }
29
32
  require 'do_postgres'
30
33
 
31
34
  log_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'log', 'do.log'))
@@ -111,8 +114,8 @@ module DataObjectsSpecHelpers
111
114
  EOF
112
115
 
113
116
  1.upto(16) do |n|
114
- conn.create_command(<<-EOF).execute_non_query
115
- insert into widgets(code, name, shelf_location, description, image_data, ad_description, ad_image, whitepaper_text, cad_drawing, super_number, weight) VALUES ('W#{n.to_s.rjust(7,"0")}', 'Widget #{n}', 'A14', 'This is a description', 'IMAGE DATA', 'Buy this product now!', 'AD IMAGE DATA', 'String', 'CAD \\001 \\000 DRAWING'::bytea, 1234, 13.4);
117
+ conn.create_command(<<-EOF).execute_non_query(::Extlib::ByteArray.new("CAD \001 \000 DRAWING"))
118
+ insert into widgets(code, name, shelf_location, description, image_data, ad_description, ad_image, whitepaper_text, cad_drawing, super_number, weight) VALUES ('W#{n.to_s.rjust(7,"0")}', 'Widget #{n}', 'A14', 'This is a description', 'IMAGE DATA', 'Buy this product now!', 'AD IMAGE DATA', 'String', ?, 1234, 13.4)
116
119
  EOF
117
120
  end
118
121
 
@@ -124,6 +127,30 @@ module DataObjectsSpecHelpers
124
127
  update widgets set ad_description = NULL where id = 3
125
128
  EOF
126
129
 
130
+ conn.create_command(<<-EOF).execute_non_query
131
+ update widgets set flags = NULL where id = 4
132
+ EOF
133
+
134
+ conn.create_command(<<-EOF).execute_non_query
135
+ update widgets set cost1 = NULL where id = 5
136
+ EOF
137
+
138
+ conn.create_command(<<-EOF).execute_non_query
139
+ update widgets set cost2 = NULL where id = 6
140
+ EOF
141
+
142
+ conn.create_command(<<-EOF).execute_non_query
143
+ update widgets set release_date = NULL where id = 7
144
+ EOF
145
+
146
+ conn.create_command(<<-EOF).execute_non_query
147
+ update widgets set release_datetime = NULL where id = 8
148
+ EOF
149
+
150
+ conn.create_command(<<-EOF).execute_non_query
151
+ update widgets set release_timestamp = NULL where id = 9
152
+ EOF
153
+
127
154
  conn.close
128
155
 
129
156
  end
data/tasks/gem.rake CHANGED
@@ -1,61 +1,8 @@
1
1
  require 'rubygems/package_task'
2
2
 
3
- GEM_SPEC = Gem::Specification.new do |s|
4
- # basic information
5
- s.name = "do_postgres"
6
- s.version = DataObjects::Postgres::VERSION
7
-
8
- # description and details
9
- s.summary = 'DataObjects PostgreSQL Driver'
10
- s.description = "Implements the DataObjects API for PostgreSQL"
11
-
12
- # dependencies
13
- s.add_dependency "addressable", "~>2.0.0"
14
- s.add_dependency "extlib", "~>0.9.12"
15
- s.add_dependency "data_objects", DataObjects::Postgres::VERSION
16
-
17
- if JRUBY
18
- s.add_dependency "jdbc-postgres", ">=8.2"
19
- s.add_dependency "do_jdbc", DataObjects::Postgres::VERSION
20
- s.platform = "java"
21
- # components, files and paths
22
- s.files = FileList["lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake",
23
- "LICENSE", "Rakefile", "*.{rdoc,txt,yml}", "lib/*.jar"]
24
- else
25
- s.platform = Gem::Platform::RUBY
26
- s.extensions << 'ext/do_postgres_ext/extconf.rb'
27
- # components, files and paths
28
- s.files = FileList["lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake", "ext/**/*.{rb,c}",
29
- "LICENSE", "Rakefile", "*.{rdoc,txt,yml}"]
30
- end
31
-
32
- # development dependencies
33
- s.add_development_dependency 'rspec', '~>1.2.0'
34
-
35
-
36
- s.require_path = 'lib'
37
-
38
- # documentation
39
- s.has_rdoc = false
40
-
41
- # project information
42
- s.homepage = 'http://github.com/datamapper/do'
43
- s.rubyforge_project = 'dorb'
44
-
45
- # author and contributors
46
- s.author = 'Dirkjan Bussink'
47
- s.email = 'd.bussink@gmail.com'
48
- end
3
+ GEM_SPEC = eval(File.read('do_postgres.gemspec'))
49
4
 
50
5
  gem_package = Gem::PackageTask.new(GEM_SPEC) do |pkg|
51
6
  pkg.need_tar = false
52
7
  pkg.need_zip = false
53
8
  end
54
-
55
- file "#{GEM_SPEC.name}.gemspec" => ['Rakefile', 'tasks/gem.rake'] do |t|
56
- puts "Generating #{t.name}"
57
- File.open(t.name, 'w') { |f| f.puts GEM_SPEC.to_yaml }
58
- end
59
-
60
- desc "Generate or update the standalone gemspec file for the project"
61
- task :gemspec => ["#{GEM_SPEC.name}.gemspec"]
data/tasks/release.rake CHANGED
@@ -8,7 +8,7 @@ end
8
8
  if defined?(RubyForge) then
9
9
  if defined?(GEM_SPEC) then
10
10
  desc 'Package and upload to RubyForge'
11
- task :release => [:package] do |t|
11
+ task :release do |t|
12
12
  ver = ENV['VERSION'] or fail "Must supply VERSION (rake release VERSION=x.y.z)."
13
13
 
14
14
  # compare versions to avoid mistakes
@@ -26,19 +26,19 @@ if defined?(RubyForge) then
26
26
 
27
27
  # read project info and overview
28
28
  notes = begin
29
- r = File.read("README.rdoc")
30
- r.split(/^(=+ .*)/)[1..4].join.strip
29
+ r = File.read("README.markdown")
30
+ r.split(/^(.*\n\-+)/)[1..4].join.strip
31
31
  rescue
32
- warn "Missing README.rdoc"
32
+ warn "Missing README.markdown"
33
33
  ''
34
34
  end
35
35
 
36
36
  # read changes
37
37
  changes = begin
38
- h = File.read("History.txt")
39
- h.split(/^(==+ .*)/)[1..2].join.strip
38
+ h = File.read("HISTORY.markdown")
39
+ h.split(/^(##+ .*)/)[1..2].join.strip
40
40
  rescue
41
- warn "Missing History.txt"
41
+ warn "Missing HISTORY.markdown"
42
42
  ''
43
43
  end
44
44
 
data/tasks/retrieve.rake CHANGED
@@ -41,9 +41,8 @@ begin
41
41
  url = "http://wwwmaster.postgresql.org/redir/107/h/binary/v#{version}/win32/#{File.basename(t.name)}"
42
42
  when_writing "downloading #{t.name}" do
43
43
  cd File.dirname(t.name) do
44
- sh "wget -c #{url} || curl -C - -O #{url}"
44
+ sh "wget -c #{url} || curl -L -C - -O #{url}"
45
45
  end
46
- touch t.name
47
46
  end
48
47
  end
49
48
 
data/tasks/spec.rake CHANGED
@@ -5,6 +5,7 @@ desc 'Run specifications'
5
5
  Spec::Rake::SpecTask.new(:spec => [ :clean, :compile ]) do |t|
6
6
  t.spec_opts << '--options' << ROOT + 'spec/spec.opts'
7
7
  t.spec_files = Pathname.glob(ENV['FILES'] || 'spec/**/*_spec.rb').map { |f| f.to_s }
8
+ t.libs << 'lib'
8
9
 
9
10
  begin
10
11
  # RCov is run by default, except on the JRuby platform
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: do_postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.12
4
+ version: 0.10.0
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Dirkjan Bussink
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-17 00:00:00 +02:00
12
+ date: 2009-09-15 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: 2.0.0
23
+ version: "2.0"
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: extlib
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirements:
41
41
  - - "="
42
42
  - !ruby/object:Gem::Version
43
- version: 0.9.12
43
+ version: 0.10.0
44
44
  version:
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: rspec
@@ -61,6 +61,7 @@ extensions: []
61
61
  extra_rdoc_files: []
62
62
 
63
63
  files:
64
+ - lib/do_postgres/encoding.rb
64
65
  - lib/do_postgres/transaction.rb
65
66
  - lib/do_postgres/version.rb
66
67
  - lib/do_postgres.rb
@@ -92,13 +93,15 @@ files:
92
93
  - tasks/spec.rake
93
94
  - ext/do_postgres_ext/extconf.rb
94
95
  - ext/do_postgres_ext/do_postgres_ext.c
96
+ - ext/do_postgres_ext/error.h
97
+ - ext/do_postgres_ext/pg_config.h
95
98
  - LICENSE
96
99
  - Rakefile
97
- - History.txt
100
+ - HISTORY.markdown
101
+ - README.markdown
98
102
  - Manifest.txt
99
- - README.txt
100
103
  - lib/do_postgres_ext.so
101
- has_rdoc: true
104
+ has_rdoc: false
102
105
  homepage: http://github.com/datamapper/do
103
106
  licenses: []
104
107
 
@@ -109,9 +112,9 @@ require_paths:
109
112
  - lib
110
113
  required_ruby_version: !ruby/object:Gem::Requirement
111
114
  requirements:
112
- - - ~>
115
+ - - ">="
113
116
  - !ruby/object:Gem::Version
114
- version: 1.8.6
117
+ version: "0"
115
118
  version:
116
119
  required_rubygems_version: !ruby/object:Gem::Requirement
117
120
  requirements:
@@ -122,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
125
  requirements: []
123
126
 
124
127
  rubyforge_project: dorb
125
- rubygems_version: 1.3.3
128
+ rubygems_version: 1.3.5
126
129
  signing_key:
127
130
  specification_version: 3
128
131
  summary: DataObjects PostgreSQL Driver