do_postgres 0.9.12-java → 0.10.0-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,12 @@
1
- == 0.9.11 2009-01-19
1
+ ## 0.9.12 2009-05-17
2
+ * Improvements
3
+ * Windows support
4
+
5
+ ## 0.9.11 2009-01-19
2
6
  * Improvements
3
7
  * Ruby 1.9 support
4
8
  * Fixes
5
9
  * Fix build issue on certain platforms introduces with 0.9.10
6
10
 
7
- == 0.9.9 2008-11-27
11
+ ## 0.9.9 2008-11-27
8
12
  * No changes since 0.9.8
data/Manifest.txt CHANGED
@@ -1,8 +1,8 @@
1
1
  .gitignore
2
- History.txt
2
+ HISTORY.markdown
3
3
  LICENSE
4
4
  Manifest.txt
5
- README.txt
5
+ README.markdown
6
6
  Rakefile
7
7
  autobuild.rb
8
8
  buildfile
@@ -1,3 +1,4 @@
1
- = do_postgres
1
+ do_postgres
2
+ ===========
2
3
 
3
4
  A PostgreSQL driver for DataObjects
data/Rakefile CHANGED
@@ -8,9 +8,9 @@ require 'lib/do_postgres/version'
8
8
  ROOT = Pathname(__FILE__).dirname.expand_path
9
9
  JRUBY = RUBY_PLATFORM =~ /java/
10
10
  WINDOWS = Gem.win_platform?
11
- SUDO = (WINDOWS || JRUBY) ? '' : ('sudo' unless ENV['SUDOLESS'])
11
+ SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])
12
12
  BINARY_VERSION = '5.0.77'
13
13
 
14
- Dir['tasks/*.rake'].each { |f| import f }
14
+ Dir['tasks/*.rake'].sort.each { |f| import f }
15
15
 
16
16
  CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext/do_postgres_ext/Makefile ext-java/target ])
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
- pkg.need_tar = false
52
- pkg.need_zip = false
6
+ pkg.need_tar = true
7
+ pkg.need_zip = true
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
@@ -28,6 +28,7 @@ specification_version: 3
28
28
  default_executable:
29
29
  files:
30
30
  - lib/do_postgres.rb
31
+ - lib/do_postgres/encoding.rb
31
32
  - lib/do_postgres/transaction.rb
32
33
  - lib/do_postgres/version.rb
33
34
  - spec/command_spec.rb
@@ -58,9 +59,9 @@ files:
58
59
  - tasks/spec.rake
59
60
  - LICENSE
60
61
  - Rakefile
61
- - History.txt
62
+ - HISTORY.markdown
63
+ - README.markdown
62
64
  - Manifest.txt
63
- - README.txt
64
65
  - lib/do_postgres_ext.jar
65
66
  required_rubygems_version: !ruby/object:Gem::Requirement
66
67
  requirements:
@@ -70,17 +71,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
71
  version:
71
72
  extensions: []
72
73
 
73
- rubygems_version: 1.3.2
74
+ rubygems_version: 1.3.3
74
75
  requirements: []
75
76
 
76
77
  authors:
77
78
  - Dirkjan Bussink
78
- date: 2009-05-16 22:00:00 +00:00
79
+ date: 2009-09-19 22:00:00 +00:00
79
80
  platform: java
80
81
  test_files: []
81
82
 
82
83
  version: !ruby/object:Gem::Version
83
- version: 0.9.12
84
+ version: 0.10.0
84
85
  require_paths:
85
86
  - lib
86
87
  dependencies:
@@ -89,7 +90,7 @@ dependencies:
89
90
  requirements:
90
91
  - - ~>
91
92
  - !ruby/object:Gem::Version
92
- version: 2.0.0
93
+ version: "2.0"
93
94
  version:
94
95
  type: :runtime
95
96
  version_requirement:
@@ -109,7 +110,7 @@ dependencies:
109
110
  requirements:
110
111
  - - "="
111
112
  - !ruby/object:Gem::Version
112
- version: 0.9.12
113
+ version: 0.10.0
113
114
  version:
114
115
  type: :runtime
115
116
  version_requirement:
@@ -129,7 +130,7 @@ dependencies:
129
130
  requirements:
130
131
  - - "="
131
132
  - !ruby/object:Gem::Version
132
- version: 0.9.12
133
+ version: 0.10.0
133
134
  version:
134
135
  type: :runtime
135
136
  version_requirement:
@@ -145,4 +146,4 @@ dependencies:
145
146
  version_requirement:
146
147
  name: rspec
147
148
  bindir: bin
148
- has_rdoc: false
149
+ has_rdoc: true