mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
mssql_session - Handling cases where the data is nil (#2752)
* Fixing bug where the row data returned is nil Signed-off-by: Noel Georgi <noel.georgi@reancloud.com>
This commit is contained in:
parent
24d5a9832e
commit
dd033fbf1b
2 changed files with 20 additions and 1 deletions
|
@ -10,7 +10,7 @@ module DatabaseHelper
|
|||
end
|
||||
|
||||
def value
|
||||
@row[@name.downcase]
|
||||
@row.nil? ? '' : @row[@name.downcase]
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
|
19
test/unit/utils/database_helpers_test.rb
Normal file
19
test/unit/utils/database_helpers_test.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
# encoding: utf-8
|
||||
|
||||
require 'helper'
|
||||
|
||||
describe DatabaseHelper do
|
||||
describe DatabaseHelper::SQLColumn do
|
||||
def column(row = { 'test' => 'value' })
|
||||
DatabaseHelper::SQLColumn.new(row, 'test')
|
||||
end
|
||||
|
||||
it 'has a valid column value' do
|
||||
column.value.must_equal 'value'
|
||||
end
|
||||
|
||||
it 'returns empty when nil' do
|
||||
column(nil).value.must_equal ''
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue