Skip to content

Commit 364206b

Browse files
authored
Handle SYBVARIANT types from SQL function. Fixes #317. Fixed #321.
Since we can not rely on determining the type from SYBVARIANT we rely on checking for a simple 4-byte (assumed integer) since this is the first time we have encountered it. Else, return binary/string representation.
1 parent f29b122 commit 364206b

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
* 1.0.6 *
22

3+
* Handle SYBVARIANT types from SQL function. Fixes #317. Fixed #321.
34
* Fix `use_utf16` optoin for booleans. Fixes #314
45
* Add `-q` check for bin puts. Fixes #318
56
* Use FreeTDS 1.00.21.

ext/tiny_tds/result.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,15 @@ static VALUE rb_tinytds_result_fetch_row(VALUE self, ID timezone, int symbolize_
325325
case SYBTEXT:
326326
val = ENCODED_STR_NEW(data, data_len);
327327
break;
328+
case 98: { // SYBVARIANT
329+
if (data_len == 4) {
330+
val = INT2NUM(*(DBINT *)data);
331+
break;
332+
} else {
333+
val = ENCODED_STR_NEW(data, data_len);
334+
break;
335+
}
336+
}
328337
default:
329338
val = ENCODED_STR_NEW(data, data_len);
330339
break;

test/result_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,11 @@ class ResultTest < TinyTds::TestCase
335335
assert_nil result.return_code
336336
end
337337

338+
it 'with LOGINPROPERTY function' do
339+
v = @client.execute("SELECT LOGINPROPERTY('sa', 'IsLocked') as v").first['v']
340+
v.must_equal 0
341+
end
342+
338343
describe 'with multiple result sets' do
339344

340345
before do

0 commit comments

Comments
 (0)