Guest User

Untitled

a guest
Jun 19th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. diff --git a/ext/tiny_tds/result.c b/ext/tiny_tds/result.c
  2. index 3f6b0eb..f62c8cd 100644
  3. --- a/ext/tiny_tds/result.c
  4. +++ b/ext/tiny_tds/result.c
  5. @@ -89,7 +89,7 @@ static VALUE rb_tinytds_result_fetch_row(VALUE self, ID timezone, int symbolize_
  6. val = INT2NUM(*(DBINT *)data);
  7. break;
  8. case SYBINT8:
  9. - val = LONG2NUM(*(long *)data);
  10. + val = LL2NUM(*(DBBIGINT *)data);
  11. break;
  12. case SYBBIT:
  13. val = *(int *)data ? Qtrue : Qfalse;
  14. @@ -116,8 +116,8 @@ static VALUE rb_tinytds_result_fetch_row(VALUE self, ID timezone, int symbolize_
  15. case SYBMONEY: {
  16. DBMONEY *money = (DBMONEY *)data;
  17. char converted_money[25];
  18. - long money_value = ((long)money->mnyhigh << 32) | money->mnylow;
  19. - sprintf(converted_money, "%ld", money_value);
  20. + long long money_value = ((long long)money->mnyhigh << 32) | money->mnylow;
  21. + sprintf(converted_money, "%lld", money_value);
  22. val = rb_funcall(cBigDecimal, intern_new, 2, rb_str_new2(converted_money), opt_four);
  23. val = rb_funcall(val, intern_divide, 1, opt_tenk);
  24. break;
  25. diff --git a/ext/tiny_tds/result.h b/ext/tiny_tds/result.h
  26. index 2e5a2e1..6c59172 100644
  27. --- a/ext/tiny_tds/result.h
  28. +++ b/ext/tiny_tds/result.h
  29. @@ -2,6 +2,8 @@
  30. #ifndef TINYTDS_RESULT_H
  31. #define TINYTDS_RESULT_H
  32.  
  33. +typedef tds_sysdep_int64_type DBBIGINT; /* Missing in sybdb.h ?!?! */
  34. +
  35. void init_tinytds_result();
  36. VALUE rb_tinytds_new_result_obj(DBPROCESS *c);
  37.  
  38. diff --git a/test/client_test.rb b/test/client_test.rb
  39. index 4680ae8..940531b 100644
  40. --- a/test/client_test.rb
  41. +++ b/test/client_test.rb
  42. @@ -33,7 +33,7 @@ class ClientTest < TinyTds::TestCase
  43. end
  44.  
  45. should 'allow valid iconv character set' do
  46. - ['CP1251', 'ISO-8859-1'].each do |encoding|
  47. + ['CP850', 'CP1252', 'ISO-8859-1'].each do |encoding|
  48. client = TinyTds::Client.new(connection_options.merge(:encoding => encoding))
  49. assert_equal encoding, client.charset
  50. assert_equal Encoding.find(encoding), client.encoding if ruby19?
  51. @@ -52,10 +52,9 @@ class ClientTest < TinyTds::TestCase
  52. options = connection_options.merge :login_timeout => 1, :dataserver => '127.0.0.2'
  53. action = lambda { TinyTds::Client.new(options) }
  54. assert_raise_tinytds_error(action) do |e|
  55. - assert_match(/unable to (open|connect)/i, e.message)
  56. - assert_equal 9, e.severity
  57. assert [20008,20009].include?(e.db_error_number)
  58. - assert_equal 36, e.os_error_number
  59. + assert_equal 9, e.severity
  60. + assert_match %r{unable to (open|connect)}i, e.message, 'ignore if non-english test run'
  61. end
  62. end
  63.  
  64. @@ -63,10 +62,9 @@ class ClientTest < TinyTds::TestCase
  65. options = connection_options.merge :username => 'willnotwork'
  66. action = lambda { TinyTds::Client.new(options) }
  67. assert_raise_tinytds_error(action) do |e|
  68. - assert_match(/login failed/i, e.message)
  69. - assert_equal 14, e.severity
  70. assert_equal 18456, e.db_error_number
  71. - assert_equal 1, e.os_error_number
  72. + assert_equal 14, e.severity
  73. + assert_match %r{login failed}i, e.message, 'ignore if non-english test run'
  74. end
  75. end
  76.  
  77. @@ -74,9 +72,9 @@ class ClientTest < TinyTds::TestCase
  78. options = connection_options.merge :encoding => 'ISO-WTF'
  79. action = lambda { TinyTds::Client.new(options) }
  80. assert_raise_tinytds_error(action) do |e|
  81. - assert_match(/unexpected eof from the server/i, e.message)
  82. - assert_equal 9, e.severity
  83. assert_equal 20017, e.db_error_number
  84. + assert_equal 9, e.severity
  85. + assert_match %r{unexpected eof from the server}i, e.message, 'ignore if non-english test run'
  86. end
  87. end
Add Comment
Please, Sign In to add comment