do_postgres 0.10.0-x86-mingw32 → 0.10.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.markdown +22 -0
- data/LICENSE +1 -1
- data/README.markdown +106 -3
- data/Rakefile +56 -9
- data/ext/do_postgres/compat.h +55 -0
- data/ext/{do_postgres_ext/do_postgres_ext.c → do_postgres/do_postgres.c} +42 -49
- data/ext/{do_postgres_ext → do_postgres}/error.h +0 -0
- data/ext/{do_postgres_ext → do_postgres}/extconf.rb +4 -3
- data/ext/{do_postgres_ext → do_postgres}/pg_config.h +0 -0
- data/lib/do_postgres.rb +12 -16
- 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 +2 -2
- data/spec/connection_spec.rb +22 -7
- data/spec/encoding_spec.rb +2 -1
- data/spec/reader_spec.rb +1 -1
- data/spec/result_spec.rb +12 -13
- data/spec/spec_helper.rb +27 -36
- data/spec/typecast/array_spec.rb +1 -1
- data/spec/typecast/bigdecimal_spec.rb +2 -2
- data/spec/typecast/boolean_spec.rb +2 -2
- data/spec/typecast/byte_array_spec.rb +1 -1
- data/spec/typecast/class_spec.rb +1 -1
- data/spec/typecast/date_spec.rb +2 -2
- data/spec/typecast/datetime_spec.rb +2 -2
- data/spec/typecast/float_spec.rb +2 -2
- data/spec/typecast/integer_spec.rb +1 -1
- data/spec/typecast/nil_spec.rb +3 -3
- data/spec/typecast/other_spec.rb +8 -0
- data/spec/typecast/range_spec.rb +1 -1
- data/spec/typecast/string_spec.rb +1 -1
- data/spec/typecast/time_spec.rb +1 -1
- data/tasks/compile.rake +81 -0
- data/tasks/release.rake +12 -71
- data/tasks/retrieve.rake +5 -9
- data/tasks/spec.rake +19 -15
- metadata +76 -39
- data/HISTORY.markdown +0 -12
- data/Manifest.txt +0 -34
- data/lib/do_postgres_ext.so +0 -0
- data/spec/lib/rspec_immediate_feedback_formatter.rb +0 -3
- data/tasks/gem.rake +0 -8
- data/tasks/install.rake +0 -15
- data/tasks/native.rake +0 -35
File without changes
|
@@ -2,6 +2,9 @@ ENV["RC_ARCHS"] = "" if RUBY_PLATFORM =~ /darwin/
|
|
2
2
|
|
3
3
|
require 'mkmf'
|
4
4
|
|
5
|
+
# Allow for custom compiler to be specified.
|
6
|
+
RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
|
7
|
+
|
5
8
|
def config_value(type)
|
6
9
|
ENV["POSTGRES_#{type.upcase}"] || pg_config(type)
|
7
10
|
end
|
@@ -23,19 +26,17 @@ dir_config('pgsql-server', config_value('includedir-server'), config_value('libd
|
|
23
26
|
dir_config('pgsql-client', config_value('includedir'), config_value('libdir'))
|
24
27
|
dir_config('pgsql-win32') if RUBY_PLATFORM =~ /mswin|mingw/
|
25
28
|
|
26
|
-
required_libraries = []
|
27
29
|
desired_functions = %w(PQsetClientEncoding pg_encoding_to_char PQfreemem)
|
28
30
|
compat_functions = %w(PQescapeString PQexecParams)
|
29
31
|
|
30
32
|
if have_build_env
|
31
|
-
required_libraries.each(&method(:have_library))
|
32
33
|
desired_functions.each(&method(:have_func))
|
33
34
|
$CFLAGS << ' -Wall ' unless RUBY_PLATFORM =~ /mswin/
|
34
35
|
if RUBY_VERSION < '1.8.6'
|
35
36
|
$CFLAGS << ' -DRUBY_LESS_THAN_186'
|
36
37
|
end
|
37
38
|
|
38
|
-
create_makefile("
|
39
|
+
create_makefile("do_postgres/do_postgres")
|
39
40
|
else
|
40
41
|
puts 'Could not find PostgreSQL build environment (libraries & headers): Makefile not created'
|
41
42
|
exit(1)
|
File without changes
|
data/lib/do_postgres.rb
CHANGED
@@ -17,21 +17,17 @@ if RUBY_PLATFORM =~ /java/
|
|
17
17
|
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
require 'do_postgres/
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
module Postgres
|
29
|
-
class Connection
|
30
|
-
def self.pool_size
|
31
|
-
20
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
20
|
+
begin
|
21
|
+
require 'do_postgres/do_postgres'
|
22
|
+
rescue LoadError
|
23
|
+
if RUBY_PLATFORM =~ /mingw|mswin/ then
|
24
|
+
RUBY_VERSION =~ /(\d+.\d+)/
|
25
|
+
require "do_postgres/#{$1}/do_postgres"
|
26
|
+
else
|
27
|
+
raise
|
35
28
|
end
|
36
|
-
|
37
29
|
end
|
30
|
+
|
31
|
+
require 'do_postgres/version'
|
32
|
+
require 'do_postgres/transaction' if RUBY_PLATFORM !~ /java/
|
33
|
+
require 'do_postgres/encoding'
|
Binary file
|
Binary file
|
data/lib/do_postgres/version.rb
CHANGED
data/spec/command_spec.rb
CHANGED
@@ -4,6 +4,6 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
|
4
4
|
require 'data_objects/spec/command_spec'
|
5
5
|
|
6
6
|
describe DataObjects::Postgres::Command do
|
7
|
-
|
8
|
-
|
7
|
+
behaves_like 'a Command'
|
8
|
+
behaves_like 'a Command with async'
|
9
9
|
end
|
data/spec/connection_spec.rb
CHANGED
@@ -5,15 +5,30 @@ require 'data_objects/spec/connection_spec'
|
|
5
5
|
|
6
6
|
describe DataObjects::Postgres::Connection do
|
7
7
|
|
8
|
-
before
|
9
|
-
@driver
|
10
|
-
@user
|
8
|
+
before 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
|
-
|
17
|
+
behaves_like 'a Connection'
|
18
|
+
behaves_like 'a Connection with authentication support'
|
19
|
+
# FIXME: behaves_like 'a Connection with JDBC URL support' if JRUBY
|
20
|
+
|
21
|
+
describe 'byte array quoting' do
|
22
|
+
it 'should properly escape non-printable ASCII characters' do
|
23
|
+
@connection.quote_byte_array("\001").should.match(/'\\?\\001'/)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should properly escape bytes with the high bit set' do
|
27
|
+
@connection.quote_byte_array("\210").should.match(/'\\?\\210'/)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should not escape printable ASCII characters' do
|
31
|
+
@connection.quote_byte_array("a").should == "'a'"
|
32
|
+
end
|
33
|
+
end
|
19
34
|
end
|
data/spec/encoding_spec.rb
CHANGED
@@ -14,6 +14,7 @@ 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
|
-
|
17
|
+
behaves_like 'a driver supporting different encodings'
|
18
|
+
behaves_like 'returning correctly encoded strings for the default encoding'
|
18
19
|
end
|
19
20
|
end
|
data/spec/reader_spec.rb
CHANGED
data/spec/result_spec.rb
CHANGED
@@ -4,24 +4,24 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
|
4
4
|
require 'data_objects/spec/result_spec'
|
5
5
|
|
6
6
|
describe DataObjects::Postgres::Result do
|
7
|
-
|
7
|
+
behaves_like 'a Result'
|
8
8
|
|
9
|
-
|
9
|
+
after do
|
10
10
|
setup_test_environment
|
11
11
|
end
|
12
12
|
|
13
13
|
describe 'without using RETURNING' do
|
14
14
|
|
15
|
-
before
|
15
|
+
before do
|
16
16
|
@connection = DataObjects::Connection.new(CONFIG.uri)
|
17
17
|
@result = @connection.create_command("INSERT INTO users (name) VALUES (?)").execute_non_query("monkey")
|
18
18
|
end
|
19
19
|
|
20
|
-
after
|
20
|
+
after do
|
21
21
|
@connection.close
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
24
|
+
it 'should respond to #affected_rows' do @result.should.respond_to(:affected_rows) end
|
25
25
|
|
26
26
|
describe 'affected_rows' do
|
27
27
|
|
@@ -31,19 +31,18 @@ describe DataObjects::Postgres::Result do
|
|
31
31
|
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
34
|
+
it 'should respond to #insert_id' do @result.should.respond_to(:insert_id) end
|
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
|
44
43
|
reader = @connection.create_command("SELECT currval('users_id_seq')").execute_reader
|
45
44
|
reader.next!
|
46
|
-
reader.values.first.should ==
|
45
|
+
reader.values.first.should == 2
|
47
46
|
end
|
48
47
|
|
49
48
|
end
|
@@ -52,16 +51,16 @@ describe DataObjects::Postgres::Result do
|
|
52
51
|
|
53
52
|
describe 'when using RETURNING' do
|
54
53
|
|
55
|
-
before
|
54
|
+
before do
|
56
55
|
@connection = DataObjects::Connection.new(CONFIG.uri)
|
57
56
|
@result = @connection.create_command("INSERT INTO users (name) VALUES (?) RETURNING id").execute_non_query("monkey")
|
58
57
|
end
|
59
58
|
|
60
|
-
after
|
59
|
+
after do
|
61
60
|
@connection.close
|
62
61
|
end
|
63
62
|
|
64
|
-
it
|
63
|
+
it 'should respond to #affected_rows' do @result.should.respond_to(:affected_rows) end
|
65
64
|
|
66
65
|
describe 'affected_rows' do
|
67
66
|
|
@@ -71,7 +70,7 @@ describe DataObjects::Postgres::Result do
|
|
71
70
|
|
72
71
|
end
|
73
72
|
|
74
|
-
it
|
73
|
+
it 'should respond to #insert_id' do @result.should.respond_to(:insert_id) end
|
75
74
|
|
76
75
|
describe 'insert_id' do
|
77
76
|
|
data/spec/spec_helper.rb
CHANGED
@@ -2,55 +2,44 @@ $TESTING=true
|
|
2
2
|
JRUBY = RUBY_PLATFORM =~ /java/
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
|
-
|
6
|
-
gem 'rspec', '>1.1.12'
|
7
|
-
require 'spec'
|
8
|
-
|
9
5
|
require 'date'
|
10
6
|
require 'ostruct'
|
11
|
-
require 'pathname'
|
12
7
|
require 'fileutils'
|
8
|
+
require 'win32console' if RUBY_PLATFORM =~ /mingw|mswin/
|
9
|
+
|
10
|
+
driver_lib = File.expand_path('../../lib', __FILE__)
|
11
|
+
$LOAD_PATH.unshift(driver_lib) unless $LOAD_PATH.include?(driver_lib)
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
$LOAD_PATH.unshift do_lib_path unless $LOAD_PATH.include?(do_lib_path)
|
21
|
-
|
22
|
-
if JRUBY
|
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)
|
25
|
-
require 'do_jdbc'
|
13
|
+
# Prepend data_objects/do_jdbc in the repository to the load path.
|
14
|
+
# DO NOT USE installed gems, except when running the specs from gem.
|
15
|
+
repo_root = File.expand_path('../../..', __FILE__)
|
16
|
+
(['data_objects'] << ('do_jdbc' if JRUBY)).compact.each do |lib|
|
17
|
+
lib_path = "#{repo_root}/#{lib}/lib"
|
18
|
+
$LOAD_PATH.unshift(lib_path) if File.directory?(lib_path) && !$LOAD_PATH.include?(lib_path)
|
26
19
|
end
|
27
20
|
|
28
21
|
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 }
|
22
|
+
require 'data_objects/spec/bacon'
|
32
23
|
require 'do_postgres'
|
33
24
|
|
34
|
-
|
35
|
-
FileUtils.mkdir_p(File.dirname(log_path))
|
36
|
-
|
37
|
-
DataObjects::Postgres.logger = DataObjects::Logger.new(log_path, :debug)
|
38
|
-
|
25
|
+
DataObjects::Postgres.logger = DataObjects::Logger.new(STDOUT, :off)
|
39
26
|
at_exit { DataObjects.logger.flush }
|
40
27
|
|
41
|
-
|
42
|
-
|
28
|
+
CONFIG = OpenStruct.new
|
29
|
+
CONFIG.scheme = 'postgres'
|
30
|
+
CONFIG.user = ENV['DO_POSTGRES_USER'] || 'postgres'
|
31
|
+
CONFIG.pass = ENV['DO_POSTGRES_PASS'] || ''
|
32
|
+
CONFIG.user_info = unless CONFIG.pass.empty?
|
33
|
+
"#{CONFIG.user}:#{CONFIG.pass}@"
|
34
|
+
else
|
35
|
+
"#{CONFIG.user}@"
|
43
36
|
end
|
37
|
+
CONFIG.host = ENV['DO_POSTGRES_HOST'] || 'localhost'
|
38
|
+
CONFIG.port = ENV['DO_POSTGRES_PORT'] || '5432'
|
39
|
+
CONFIG.database = ENV['DO_POSTGRES_DATABASE'] || '/do_test'
|
44
40
|
|
45
|
-
CONFIG =
|
46
|
-
CONFIG.
|
47
|
-
CONFIG.user = ENV['DO_POSTGRES_USER'] || 'postgres'
|
48
|
-
CONFIG.pass = ENV['DO_POSTGRES_PASS'] || ''
|
49
|
-
CONFIG.host = ENV['DO_POSTGRES_HOST'] || 'localhost'
|
50
|
-
CONFIG.port = ENV['DO_POSTGRES_PORT'] || '5432'
|
51
|
-
CONFIG.database = ENV['DO_POSTGRES_DATABASE'] || '/do_test'
|
52
|
-
|
53
|
-
CONFIG.uri = ENV["DO_POSTGRES_SPEC_URI"] ||"#{CONFIG.scheme}://#{CONFIG.user}:#{CONFIG.pass}@#{CONFIG.host}:#{CONFIG.port}#{CONFIG.database}"
|
41
|
+
CONFIG.uri = ENV["DO_POSTGRES_SPEC_URI"] ||"#{CONFIG.scheme}://#{CONFIG.user_info}#{CONFIG.host}:#{CONFIG.port}#{CONFIG.database}"
|
42
|
+
CONFIG.jdbc_uri = CONFIG.uri.sub(/postgres/,"jdbc:postgresql")
|
54
43
|
CONFIG.sleep = "SELECT pg_sleep(1)"
|
55
44
|
|
56
45
|
module DataObjectsSpecHelpers
|
@@ -156,3 +145,5 @@ module DataObjectsSpecHelpers
|
|
156
145
|
end
|
157
146
|
|
158
147
|
end
|
148
|
+
|
149
|
+
include DataObjectsSpecHelpers
|
data/spec/typecast/array_spec.rb
CHANGED
@@ -4,6 +4,6 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
|
4
4
|
require 'data_objects/spec/typecast/bigdecimal_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with BigDecimal' do
|
7
|
-
|
8
|
-
|
7
|
+
behaves_like 'supporting BigDecimal'
|
8
|
+
behaves_like 'supporting BigDecimal autocasting'
|
9
9
|
end
|
@@ -4,6 +4,6 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
|
4
4
|
require 'data_objects/spec/typecast/boolean_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with Boolean' do
|
7
|
-
|
8
|
-
|
7
|
+
behaves_like 'supporting Boolean'
|
8
|
+
behaves_like 'supporting Boolean autocasting'
|
9
9
|
end
|
@@ -4,5 +4,5 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
|
4
4
|
require 'data_objects/spec/typecast/byte_array_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with ByteArray' do
|
7
|
-
|
7
|
+
behaves_like 'supporting ByteArray'
|
8
8
|
end
|
data/spec/typecast/class_spec.rb
CHANGED
data/spec/typecast/date_spec.rb
CHANGED
@@ -4,6 +4,6 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
|
4
4
|
require 'data_objects/spec/typecast/date_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with Date' do
|
7
|
-
|
8
|
-
|
7
|
+
behaves_like 'supporting Date'
|
8
|
+
behaves_like 'supporting Date autocasting'
|
9
9
|
end
|
@@ -4,6 +4,6 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
|
4
4
|
require 'data_objects/spec/typecast/datetime_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with DateTime' do
|
7
|
-
|
8
|
-
|
7
|
+
behaves_like 'supporting DateTime'
|
8
|
+
behaves_like 'supporting DateTime autocasting'
|
9
9
|
end
|
data/spec/typecast/float_spec.rb
CHANGED
@@ -4,6 +4,6 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
|
4
4
|
require 'data_objects/spec/typecast/float_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with Float' do
|
7
|
-
|
8
|
-
|
7
|
+
behaves_like 'supporting Float'
|
8
|
+
behaves_like 'supporting Float autocasting'
|
9
9
|
end
|
@@ -4,5 +4,5 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
|
4
4
|
require 'data_objects/spec/typecast/integer_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with Integer' do
|
7
|
-
|
7
|
+
behaves_like 'supporting Integer'
|
8
8
|
end
|
data/spec/typecast/nil_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
|
4
4
|
require 'data_objects/spec/typecast/nil_spec'
|
5
5
|
|
6
6
|
describe 'DataObjects::Postgres with Nil' do
|
7
|
-
|
8
|
-
#
|
9
|
-
|
7
|
+
behaves_like 'supporting Nil'
|
8
|
+
# behaves_like 'supporting writing an Nil'
|
9
|
+
behaves_like 'supporting Nil autocasting'
|
10
10
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
4
|
+
require 'data_objects/spec/typecast/other_spec'
|
5
|
+
|
6
|
+
describe 'DataObjects::H2 with other (unknown) type' do
|
7
|
+
behaves_like 'supporting other (unknown) type'
|
8
|
+
end
|
data/spec/typecast/range_spec.rb
CHANGED
data/spec/typecast/time_spec.rb
CHANGED