8000 Restore compatibility with PostgreSQL down to 8.3 · danielcode/ruby-pg@7cf7a61 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7cf7a61

Browse files
committed
Restore compatibility with PostgreSQL down to 8.3
1 parent 7093361 commit 7cf7a61

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

lib/pg/connection.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ def self::parse_connect_args( *args )
2424
# PQconnectdbParams()/PQconnectStartParams(). For now, stick to an options string for
2525
# PQconnectdb()/PQconnectStart().
2626

27-
appname = PG::Connection.quote_connstr( $0 )
28-
connopts = ["fallback_application_name=#{appname}"]
27+
# Parameter 'fallback_application_name' was introduced in PostgreSQL 9.0
28+
# together with PQescapeLiteral().
29+
if PG::Connection.instance_methods.find{|m| m.to_sym == :escape_literal }
30+
appname = PG::Connection.quote_connstr( $0 )
31+
connopts = ["fallback_application_name=#{appname}"]
32+
else
33+
connopts = []
34+
end
2935

3036
# Handle an options hash first
3137
if args.last.is_a?( Hash )

spec/lib/helpers.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ def ansi_code( *attributes )
4848
attributes = ANSI_ATTRIBUTES.values_at( *attributes ).compact.join(';')
4949

5050
# $stderr.puts " attr is: %p" % [attributes]
51-
if attributes.empty?
51+
if attributes.empty?
5252
return ''
5353
else
5454
return "\e[%sm" % attributes
5555
end
5656
end
5757

5858

59-
### Colorize the given +string+ with the specified +attributes+ and return it, handling
59+
### Colorize the given +string+ with the specified +attributes+ and return it, handling
6060
### line-endings, color reset, etc.
6161
def colorize( *args )
6262
string = ''
@@ -112,7 +112,7 @@ def run( *cmd )
112112

113113
NOFORK_PLATFORMS = %w{java}
114114

115-
### Run the specified command +cmd+ after redirecting stdout and stderr to the specified
115+
### Run the specified command +cmd+ after redirecting stdout and stderr to the specified
116116
### +logpath+, failing if the execution fails.
117117
def log_and_run( logpath, *cmd )
118118
cmd.flatten!
@@ -244,9 +244,10 @@ def teardown_testing_db( conn )
244244
config.filter_run_excluding :postgresql_90 unless
245245
PG::Connection.instance_methods.map( &:to_sym ).include?( :escape_literal )
246246

247-
unless PG.respond_to?( :library_version )
248-
config.filter_run_excluding( :postgresql_91 )
249-
config.filter_run_excluding( :postgresql_92 ) unless PG.library_version >= '90200'
247+
if !PG.respond_to?( :library_version )
248+
config.filter_run_excluding( :postgresql_91, :postgresql_92 )
249+
elsif PG.library_version < 90200
250+
config.filter_run_excluding( :postgresql_92 )
250251
end
251252
end
252253

0 commit comments

Comments
 (0)
0