do_postgres 0.10.3-x86-mswin32-60 → 0.10.4.rc1-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.markdown +2 -9
- data/Rakefile +12 -45
- data/ext/do_postgres/do_common.c +526 -0
- data/ext/do_postgres/do_common.h +170 -0
- data/ext/do_postgres/do_postgres.c +253 -676
- data/ext/do_postgres/error.h +126 -241
- data/lib/do_postgres.rb +8 -3
- data/lib/do_postgres/1.8/do_postgres.so +0 -0
- data/lib/do_postgres/1.9/do_postgres.so +0 -0
- data/lib/do_postgres/version.rb +1 -1
- data/spec/command_spec.rb +3 -3
- data/spec/connection_spec.rb +21 -12
- data/spec/encoding_spec.rb +4 -4
- data/spec/error/sql_error_spec.rb +2 -2
- data/spec/reader_spec.rb +2 -2
- data/spec/result_spec.rb +11 -10
- data/spec/spec_helper.rb +13 -5
- data/spec/typecast/array_spec.rb +2 -2
- data/spec/typecast/bigdecimal_spec.rb +3 -3
- data/spec/typecast/boolean_spec.rb +3 -3
- data/spec/typecast/byte_array_spec.rb +2 -2
- data/spec/typecast/class_spec.rb +2 -2
- data/spec/typecast/date_spec.rb +3 -3
- data/spec/typecast/datetime_spec.rb +3 -3
- data/spec/typecast/float_spec.rb +3 -3
- data/spec/typecast/integer_spec.rb +2 -2
- data/spec/typecast/nil_spec.rb +4 -4
- data/spec/typecast/other_spec.rb +2 -2
- data/spec/typecast/range_spec.rb +2 -2
- data/spec/typecast/string_spec.rb +2 -2
- data/spec/typecast/time_spec.rb +3 -2
- data/tasks/compile.rake +41 -44
- data/tasks/spec.rake +8 -19
- metadata +58 -55
data/lib/do_postgres.rb
CHANGED
@@ -3,9 +3,14 @@ if RUBY_PLATFORM =~ /java/
|
|
3
3
|
require 'do_jdbc'
|
4
4
|
require 'java'
|
5
5
|
|
6
|
-
|
6
|
+
module DataObjects
|
7
|
+
module Postgres
|
8
|
+
JDBC_DRIVER = 'org.postgresql.Driver'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
7
12
|
begin
|
8
|
-
java.lang.Thread.currentThread.getContextClassLoader().loadClass(
|
13
|
+
java.lang.Thread.currentThread.getContextClassLoader().loadClass(DataObjects::Postgres::JDBC_DRIVER, true)
|
9
14
|
rescue
|
10
15
|
require 'jdbc/postgres' # the JDBC driver, packaged as a gem
|
11
16
|
end
|
@@ -13,7 +18,7 @@ if RUBY_PLATFORM =~ /java/
|
|
13
18
|
# Another way of loading the JDBC Class. This seems to be more reliable
|
14
19
|
# than Class.forName() within the data_objects.Connection Java class,
|
15
20
|
# which is currently not working as expected.
|
16
|
-
java_import
|
21
|
+
java_import DataObjects::Postgres::JDBC_DRIVER
|
17
22
|
|
18
23
|
end
|
19
24
|
|
Binary file
|
Binary file
|
data/lib/do_postgres/version.rb
CHANGED
data/spec/command_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
4
|
-
require 'data_objects/spec/command_spec'
|
4
|
+
require 'data_objects/spec/shared/command_spec'
|
5
5
|
|
6
6
|
describe DataObjects::Postgres::Command do
|
7
|
-
|
8
|
-
|
7
|
+
it_should_behave_like 'a Command'
|
8
|
+
it_should_behave_like 'a Command with async'
|
9
9
|
end
|
data/spec/connection_spec.rb
CHANGED
@@ -1,24 +1,33 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
4
|
-
require 'data_objects/spec/connection_spec'
|
4
|
+
require 'data_objects/spec/shared/connection_spec'
|
5
5
|
|
6
6
|
describe DataObjects::Postgres::Connection do
|
7
7
|
|
8
|
-
before do
|
9
|
-
@driver
|
10
|
-
@user
|
8
|
+
before :all do
|
9
|
+
@driver = CONFIG.scheme
|
10
|
+
@user = CONFIG.user
|
11
11
|
@password = CONFIG.pass
|
12
|
-
@host
|
13
|
-
@port
|
12
|
+
@host = CONFIG.host
|
13
|
+
@port = CONFIG.port
|
14
14
|
@database = CONFIG.database
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
it_should_behave_like 'a Connection'
|
18
|
+
it_should_behave_like 'a Connection with authentication support'
|
19
|
+
it_should_behave_like 'a Connection with JDBC URL support' if JRUBY
|
20
20
|
|
21
21
|
describe 'byte array quoting' do
|
22
|
+
|
23
|
+
before do
|
24
|
+
@connection = DataObjects::Connection.new(CONFIG.uri)
|
25
|
+
end
|
26
|
+
|
27
|
+
after do
|
28
|
+
@connection.close
|
29
|
+
end
|
30
|
+
|
22
31
|
# There are two possible byte array quotings available: hex or escape.
|
23
32
|
# The default changed from escape to hex in version 9, so these specs
|
24
33
|
# check for either.
|
@@ -26,15 +35,15 @@ describe DataObjects::Postgres::Connection do
|
|
26
35
|
# http://developer.postgresql.org/pgdocs/postgres/datatype-binary.html
|
27
36
|
# http://developer.postgresql.org/pgdocs/postgres/release-9-0.html (E.3.2.3.)
|
28
37
|
it 'should properly escape non-printable ASCII characters' do
|
29
|
-
["'\\001'", "'\\x01'"].should
|
38
|
+
["'\\001'", "'\\x01'"].should include @connection.quote_byte_array("\001")
|
30
39
|
end
|
31
40
|
|
32
41
|
it 'should properly escape bytes with the high bit set' do
|
33
|
-
["'\\210'", "'\\x88'"].should
|
42
|
+
["'\\210'", "'\\x88'"].should include @connection.quote_byte_array("\210")
|
34
43
|
end
|
35
44
|
|
36
45
|
it 'should not escape printable ASCII characters' do
|
37
|
-
["'a'", "'\\x61'"].should
|
46
|
+
["'a'", "'\\x61'"].should include @connection.quote_byte_array("a")
|
38
47
|
end
|
39
48
|
end
|
40
49
|
end
|
data/spec/encoding_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
4
|
-
require 'data_objects/spec/encoding_spec'
|
4
|
+
require 'data_objects/spec/shared/encoding_spec'
|
5
5
|
|
6
6
|
describe DataObjects::Postgres::Connection do
|
7
7
|
unless JRUBY
|
@@ -14,8 +14,8 @@ describe DataObjects::Postgres::Connection do
|
|
14
14
|
# handles setting the internal client_encoding setting appropriately. It
|
15
15
|
# can be overridden -- but for now, we won't support doing this.
|
16
16
|
#
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
it_should_behave_like 'a driver supporting different encodings'
|
18
|
+
it_should_behave_like 'returning correctly encoded strings for the default database encoding'
|
19
|
+
it_should_behave_like 'returning correctly encoded strings for the default internal encoding'
|
20
20
|
end
|
21
21
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
-
require 'data_objects/spec/error/sql_error_spec'
|
4
|
+
require 'data_objects/spec/shared/error/sql_error_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres raising SQLError' do
|
7
|
-
|
7
|
+
it_should_behave_like 'raising a SQLError'
|
8
8
|
end
|
data/spec/reader_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
4
|
-
require 'data_objects/spec/reader_spec'
|
4
|
+
require 'data_objects/spec/shared/reader_spec'
|
5
5
|
|
6
6
|
describe DataObjects::Postgres::Reader do
|
7
|
-
|
7
|
+
it_should_behave_like 'a Reader'
|
8
8
|
end
|
data/spec/result_spec.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
4
|
-
require 'data_objects/spec/result_spec'
|
4
|
+
require 'data_objects/spec/shared/result_spec'
|
5
5
|
|
6
6
|
describe DataObjects::Postgres::Result do
|
7
|
-
|
7
|
+
it_should_behave_like 'a Result'
|
8
8
|
|
9
|
-
|
9
|
+
before do
|
10
10
|
setup_test_environment
|
11
11
|
end
|
12
12
|
|
@@ -21,7 +21,7 @@ describe DataObjects::Postgres::Result do
|
|
21
21
|
@connection.close
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
24
|
+
it { @result.should respond_to(:affected_rows) }
|
25
25
|
|
26
26
|
describe 'affected_rows' do
|
27
27
|
|
@@ -31,18 +31,19 @@ describe DataObjects::Postgres::Result do
|
|
31
31
|
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
34
|
+
it { @result.should respond_to(:insert_id) }
|
35
35
|
|
36
36
|
describe 'insert_id' do
|
37
37
|
|
38
38
|
it 'should return nil' do
|
39
|
-
@result.insert_id.should
|
39
|
+
@result.insert_id.should be_nil
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'should be retrievable through curr_val' do
|
43
|
+
# This is actually the 4th record inserted
|
43
44
|
reader = @connection.create_command("SELECT currval('users_id_seq')").execute_reader
|
44
45
|
reader.next!
|
45
|
-
reader.values.first.should ==
|
46
|
+
reader.values.first.should == 1
|
46
47
|
end
|
47
48
|
|
48
49
|
end
|
@@ -60,7 +61,7 @@ describe DataObjects::Postgres::Result do
|
|
60
61
|
@connection.close
|
61
62
|
end
|
62
63
|
|
63
|
-
it
|
64
|
+
it { @result.should respond_to(:affected_rows) }
|
64
65
|
|
65
66
|
describe 'affected_rows' do
|
66
67
|
|
@@ -70,12 +71,12 @@ describe DataObjects::Postgres::Result do
|
|
70
71
|
|
71
72
|
end
|
72
73
|
|
73
|
-
it
|
74
|
+
it { @result.should respond_to(:insert_id) }
|
74
75
|
|
75
76
|
describe 'insert_id' do
|
76
77
|
|
77
78
|
it 'should return the generated key value' do
|
78
|
-
@result.insert_id.should ==
|
79
|
+
@result.insert_id.should == 1
|
79
80
|
end
|
80
81
|
|
81
82
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,6 +2,7 @@ $TESTING=true
|
|
2
2
|
JRUBY = RUBY_PLATFORM =~ /java/
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
|
+
require 'rspec'
|
5
6
|
require 'date'
|
6
7
|
require 'ostruct'
|
7
8
|
require 'fileutils'
|
@@ -19,12 +20,14 @@ repo_root = File.expand_path('../../..', __FILE__)
|
|
19
20
|
end
|
20
21
|
|
21
22
|
require 'data_objects'
|
22
|
-
require 'data_objects/spec/
|
23
|
+
require 'data_objects/spec/setup'
|
24
|
+
require 'data_objects/spec/lib/pending_helpers'
|
23
25
|
require 'do_postgres'
|
24
26
|
|
25
27
|
DataObjects::Postgres.logger = DataObjects::Logger.new(STDOUT, :off)
|
26
28
|
at_exit { DataObjects.logger.flush }
|
27
29
|
|
30
|
+
|
28
31
|
CONFIG = OpenStruct.new
|
29
32
|
CONFIG.scheme = 'postgres'
|
30
33
|
CONFIG.user = ENV['DO_POSTGRES_USER'] || 'postgres'
|
@@ -38,9 +41,11 @@ CONFIG.host = ENV['DO_POSTGRES_HOST'] || 'localhost'
|
|
38
41
|
CONFIG.port = ENV['DO_POSTGRES_PORT'] || '5432'
|
39
42
|
CONFIG.database = ENV['DO_POSTGRES_DATABASE'] || '/do_test'
|
40
43
|
|
41
|
-
CONFIG.
|
42
|
-
CONFIG.
|
43
|
-
CONFIG.
|
44
|
+
CONFIG.driver = 'postgres'
|
45
|
+
CONFIG.jdbc_driver = DataObjects::Postgres.const_get('JDBC_DRIVER') rescue nil
|
46
|
+
CONFIG.uri = ENV["DO_POSTGRES_SPEC_URI"] ||"#{CONFIG.scheme}://#{CONFIG.user_info}#{CONFIG.host}:#{CONFIG.port}#{CONFIG.database}"
|
47
|
+
CONFIG.jdbc_uri = CONFIG.uri.sub(/postgres/,"jdbc:postgresql")
|
48
|
+
CONFIG.sleep = "SELECT pg_sleep(1)"
|
44
49
|
|
45
50
|
module DataObjectsSpecHelpers
|
46
51
|
|
@@ -149,4 +154,7 @@ module DataObjectsSpecHelpers
|
|
149
154
|
|
150
155
|
end
|
151
156
|
|
152
|
-
|
157
|
+
RSpec.configure do |config|
|
158
|
+
config.include(DataObjectsSpecHelpers)
|
159
|
+
config.include(DataObjects::Spec::PendingHelpers)
|
160
|
+
end
|
data/spec/typecast/array_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
-
require 'data_objects/spec/typecast/array_spec'
|
4
|
+
require 'data_objects/spec/shared/typecast/array_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with Array' do
|
7
|
-
|
7
|
+
it_should_behave_like 'supporting Array'
|
8
8
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
-
require 'data_objects/spec/typecast/bigdecimal_spec'
|
4
|
+
require 'data_objects/spec/shared/typecast/bigdecimal_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with BigDecimal' do
|
7
|
-
|
8
|
-
|
7
|
+
it_should_behave_like 'supporting BigDecimal'
|
8
|
+
it_should_behave_like 'supporting BigDecimal autocasting'
|
9
9
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
-
require 'data_objects/spec/typecast/boolean_spec'
|
4
|
+
require 'data_objects/spec/shared/typecast/boolean_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with Boolean' do
|
7
|
-
|
8
|
-
|
7
|
+
it_should_behave_like 'supporting Boolean'
|
8
|
+
it_should_behave_like 'supporting Boolean autocasting'
|
9
9
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
-
require 'data_objects/spec/typecast/byte_array_spec'
|
4
|
+
require 'data_objects/spec/shared/typecast/byte_array_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with ByteArray' do
|
7
|
-
|
7
|
+
it_should_behave_like 'supporting ByteArray'
|
8
8
|
end
|
data/spec/typecast/class_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
-
require 'data_objects/spec/typecast/class_spec'
|
4
|
+
require 'data_objects/spec/shared/typecast/class_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with Class' do
|
7
|
-
|
7
|
+
it_should_behave_like 'supporting Class'
|
8
8
|
end
|
data/spec/typecast/date_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
-
require 'data_objects/spec/typecast/date_spec'
|
4
|
+
require 'data_objects/spec/shared/typecast/date_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with Date' do
|
7
|
-
|
8
|
-
|
7
|
+
it_should_behave_like 'supporting Date'
|
8
|
+
it_should_behave_like 'supporting Date autocasting'
|
9
9
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
-
require 'data_objects/spec/typecast/datetime_spec'
|
4
|
+
require 'data_objects/spec/shared/typecast/datetime_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with DateTime' do
|
7
|
-
|
8
|
-
|
7
|
+
it_should_behave_like 'supporting DateTime'
|
8
|
+
it_should_behave_like 'supporting DateTime autocasting'
|
9
9
|
end
|
data/spec/typecast/float_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
-
require 'data_objects/spec/typecast/float_spec'
|
4
|
+
require 'data_objects/spec/shared/typecast/float_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with Float' do
|
7
|
-
|
8
|
-
|
7
|
+
it_should_behave_like 'supporting Float'
|
8
|
+
it_should_behave_like 'supporting Float autocasting'
|
9
9
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
-
require 'data_objects/spec/typecast/integer_spec'
|
4
|
+
require 'data_objects/spec/shared/typecast/integer_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with Integer' do
|
7
|
-
|
7
|
+
it_should_behave_like 'supporting Integer'
|
8
8
|
end
|
data/spec/typecast/nil_spec.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
-
require 'data_objects/spec/typecast/nil_spec'
|
4
|
+
require 'data_objects/spec/shared/typecast/nil_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with Nil' do
|
7
|
-
|
8
|
-
#
|
9
|
-
|
7
|
+
it_should_behave_like 'supporting Nil'
|
8
|
+
# it_should_behave_like 'supporting writing an Nil'
|
9
|
+
it_should_behave_like 'supporting Nil autocasting'
|
10
10
|
end
|
data/spec/typecast/other_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
-
require 'data_objects/spec/typecast/other_spec'
|
4
|
+
require 'data_objects/spec/shared/typecast/other_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::H2 with other (unknown) type' do
|
7
|
-
|
7
|
+
it_should_behave_like 'supporting other (unknown) type'
|
8
8
|
end
|
data/spec/typecast/range_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
-
require 'data_objects/spec/typecast/range_spec'
|
4
|
+
require 'data_objects/spec/shared/typecast/range_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with Range' do
|
7
|
-
|
7
|
+
it_should_behave_like 'supporting Range'
|
8
8
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
-
require 'data_objects/spec/typecast/string_spec'
|
4
|
+
require 'data_objects/spec/shared/typecast/string_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with String' do
|
7
|
-
|
7
|
+
it_should_behave_like 'supporting String'
|
8
8
|
end
|