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:
Noel Georgi 2018-03-02 01:00:07 +05:30 committed by Jared Quick
parent 24d5a9832e
commit dd033fbf1b
2 changed files with 20 additions and 1 deletions

View file

@ -10,7 +10,7 @@ module DatabaseHelper
end
def value
@row[@name.downcase]
@row.nil? ? '' : @row[@name.downcase]
end
def to_s

View 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