Skip to content

Commit e244d6d

Browse files
committed
Merge branch 'master' of github.com:sprsquish/vertica
2 parents 4be1a01 + 25ae69d commit e244d6d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/vertica/connection.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ def copy(sql, source = nil, &block)
129129
end
130130
return job.run
131131
end
132+
133+
def inspect
134+
safe_options = @options.reject{ |name, _| name == :password }
135+
"#<Vertica::Connection:#{object_id} @parameters=#{@parameters.inspect} @backend_pid=#{@backend_pid}, @backend_key=#{@backend_key}, @transaction_status=#{@transaction_status}, @socket=#{@socket}, @options=#{safe_options.inspect}, @row_style=#{@row_style}>"
136+
end
132137

133138
protected
134139

test/functional/connection_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,10 @@ def test_new_with_error_response
6868
Vertica::Connection.new(TEST_CONNECTION_HASH.merge('database' => 'nonexistant_db'))
6969
end
7070
end
71+
72+
def test_connection_inspect_should_not_print_password
73+
@connection = Vertica::Connection.new(TEST_CONNECTION_HASH)
74+
inspected_string = @connection.inspect
75+
assert_no_match /:password=>#{TEST_CONNECTION_HASH[:password]}/, inspected_string
76+
end
7177
end

0 commit comments

Comments
 (0)