tiny_tds 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,7 +1,12 @@
1
1
 
2
+ * 0.2.2 *
3
+
4
+ * Fixed failing test in Ruby 1.8.6. DateTime doesn't support fractional seconds greater than 59. See: http://redmine.ruby-lang.org/issues/show/1490 [Erik Bryn]
5
+
6
+
2
7
  * 0.2.1 *
3
8
 
4
- Compatibility with 32-bit systems. Better cross language testing [Klaus Gundermann]
9
+ * Compatibility with 32-bit systems. Better cross language testing. [Klaus Gundermann]
5
10
 
6
11
 
7
12
  * 0.2.0 *
data/README.rdoc CHANGED
@@ -112,6 +112,29 @@ Likewise for INSERT statements, the #insert method cancels any need for loading
112
112
  result = client.execute("INSERT INTO [datatypes] ([xml]) VALUES ('<html><br/></html>')")
113
113
  result.insert # => 420
114
114
 
115
+ The result object can handle multiple result sets form batched SQL or stored procedures. It is critical to remember that when calling each with a block for the first time will return each "row" of each result set. Calling each a second time with a block will yield each "set".
116
+
117
+ sql = ["SELECT TOP (1) [id] FROM [datatypes]",
118
+ "SELECT TOP (2) [bigint] FROM [datatypes] WHERE [bigint] IS NOT NULL"].join(' ')
119
+
120
+ set1, set2 = client.execute(sql).each
121
+ set1 # => [{"id"=>11}]
122
+ set2 # => [{"bigint"=>-9223372036854775807}, {"bigint"=>9223372036854775806}]
123
+
124
+ result = client.execute(sql)
125
+
126
+ result.each do |rowset|
127
+ # First time data loading, yields each row from each set.
128
+ # 1st: {"id"=>11}
129
+ # 2nd: {"bigint"=>-9223372036854775807}
130
+ # 3rd: {"bigint"=>9223372036854775806}
131
+ end
132
+
133
+ result.each do |rowset|
134
+ # Second time over (if columns cached), yields each set.
135
+ # 1st: [{"id"=>11}]
136
+ # 2nd: [{"bigint"=>-9223372036854775807}, {"bigint"=>9223372036854775806}]
137
+ end
115
138
 
116
139
 
117
140
  == Query Options
@@ -142,11 +165,13 @@ Besides the standard query options, the result object can take one additional op
142
165
  By default row caching is turned on because the SQL Server adapter for ActiveRecord would not work without it. I hope to find some time to create some performance patches for ActiveRecord that would allow it to take advantages of lazily created yielded rows from result objects. Currently only TinyTds and the Mysql2 gem allow such a performance gain.
143
166
 
144
167
 
168
+
145
169
  == Using TinyTds With the ActiveRecord SQL Server adapter.
146
170
 
147
- As of version 2.3.11 & 3.0.3 of the adapter, you can specify a :dblib mode in database.yml and use TinyTds as the low level connection mode. Make sure to add a :dataserver option to that matches the name in your freetds.conf file. The SQL Server adapter can be found here.
171
+ As of version 2.3.11 & 3.0.3 of the adapter, you can specify a :dblib mode in database.yml and use TinyTds as the low level connection mode. Make sure to add a :dataserver option to that matches the name in your freetds.conf file. The SQL Server adapter can be found using the link below. Also included is a direct link to the wiki article covering common questions when using TinyTds as the low level connection mode for the adapter.
148
172
 
149
173
  http://github.com/rails-sqlserver/activerecord-sqlserver-adapter
174
+ http://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Using-TinyTds
150
175
 
151
176
 
152
177
 
@@ -160,6 +185,7 @@ For help and support.
160
185
 
161
186
  * Github Source: http://github.com/rails-sqlserver/tiny_tds
162
187
  * Github Issues: http://github.com/rails-sqlserver/tiny_tds/issues
188
+ * Google Group: http://groups.google.com/group/rails-sqlserver-adapter
163
189
  * IRC Room: #rails-sqlserver on irc.freenode.net
164
190
 
165
191
  Current to do list.
@@ -3,10 +3,11 @@
3
3
 
4
4
  VALUE cTinyTdsResult;
5
5
  extern VALUE mTinyTds, cTinyTdsClient, cTinyTdsError;
6
- VALUE cBigDecimal, cDate, cDateTime, cRational;
6
+ VALUE cBigDecimal, cDate, cDateTime;
7
7
  VALUE opt_decimal_zero, opt_float_zero, opt_one, opt_zero, opt_four, opt_19hdr, opt_tenk, opt_onemil;
8
+ int opt_ruby_186;
8
9
  static ID intern_new, intern_utc, intern_local, intern_localtime, intern_merge,
9
- intern_civil, intern_new_offset, intern_plus, intern_divide;
10
+ intern_civil, intern_new_offset, intern_plus, intern_divide, intern_Rational;
10
11
  static ID sym_symbolize_keys, sym_as, sym_array, sym_cache_rows, sym_first, sym_timezone, sym_local, sym_utc;
11
12
 
12
13
  #ifdef HAVE_RUBY_ENCODING_H
@@ -137,8 +138,8 @@ static VALUE rb_tinytds_result_fetch_row(VALUE self, ID timezone, int symbolize_
137
138
  #endif
138
139
  break;
139
140
  case 36: { // SYBUNIQUE
140
- char converted_unique[36];
141
- dbconvert(rwrap->client, coltype, data, data_len, SYBVARCHAR, (BYTE *)converted_unique, sizeof(converted_unique));
141
+ char converted_unique[37];
142
+ dbconvert(rwrap->client, coltype, data, 37, SYBVARCHAR, (BYTE *)converted_unique, -1);
142
143
  val = ENCODED_STR_NEW2(converted_unique);
143
144
  break;
144
145
  }
@@ -164,12 +165,14 @@ static VALUE rb_tinytds_result_fetch_row(VALUE self, ID timezone, int symbolize_
164
165
  if (year < 1902 || year+month+day > 2058) {
165
166
  VALUE datetime_sec = INT2NUM(sec);
166
167
  if (msec != 0) {
167
- #ifdef HAVE_RUBY_ENCODING_H
168
- VALUE rational_msec = rb_Rational2(INT2NUM(msec*1000), opt_onemil);
169
- #else
170
- VALUE rational_msec = rb_funcall(cRational, intern_new, 2, INT2NUM(msec*1000), opt_onemil);
171
- #endif
172
- datetime_sec = rb_funcall(datetime_sec, intern_plus, 1, rational_msec);
168
+ if ((opt_ruby_186 == 0 && sec < 59) || (opt_ruby_186 != 0 )) {
169
+ #ifdef HAVE_RUBY_ENCODING_H
170
+ VALUE rational_msec = rb_Rational2(INT2NUM(msec*1000), opt_onemil);
171
+ #else
172
+ VALUE rational_msec = rb_funcall(rb_cObject, intern_Rational, 2, INT2NUM(msec*1000), opt_onemil);
173
+ #endif
174
+ datetime_sec = rb_funcall(datetime_sec, intern_plus, 1, rational_msec);
175
+ }
173
176
  }
174
177
  val = rb_funcall(cDateTime, intern_civil, 7, INT2NUM(year), INT2NUM(month), INT2NUM(day), INT2NUM(hour), INT2NUM(min), datetime_sec, offset);
175
178
  val = rb_funcall(val, intern_new_offset, 1, offset);
@@ -371,7 +374,6 @@ void init_tinytds_result() {
371
374
  cBigDecimal = rb_const_get(rb_cObject, rb_intern("BigDecimal"));
372
375
  cDate = rb_const_get(rb_cObject, rb_intern("Date"));
373
376
  cDateTime = rb_const_get(rb_cObject, rb_intern("DateTime"));
374
- cRational = rb_const_get(rb_cObject, rb_intern("Rational"));
375
377
  /* Define TinyTds::Result */
376
378
  cTinyTdsResult = rb_define_class_under(mTinyTds, "Result", rb_cObject);
377
379
  /* Define TinyTds::Result Public Methods */
@@ -391,6 +393,7 @@ void init_tinytds_result() {
391
393
  intern_new_offset = rb_intern("new_offset");
392
394
  intern_plus = rb_intern("+");
393
395
  intern_divide = rb_intern("/");
396
+ intern_Rational = rb_intern("Rational");
394
397
  /* Symbol Helpers */
395
398
  sym_symbolize_keys = ID2SYM(rb_intern("symbolize_keys"));
396
399
  sym_as = ID2SYM(rb_intern("as"));
@@ -411,6 +414,8 @@ void init_tinytds_result() {
411
414
  opt_19hdr = INT2NUM(1900);
412
415
  opt_tenk = INT2NUM(10000);
413
416
  opt_onemil = INT2NUM(1000000);
417
+ /* Ruby version flags */
418
+ opt_ruby_186 = strcmp(ruby_version, "1.8.6");
414
419
  /* Encoding */
415
420
  #ifdef HAVE_RUBY_ENCODING_H
416
421
  binaryEncoding = rb_enc_find("binary");
@@ -3,6 +3,7 @@
3
3
  #define MSDBLIB
4
4
 
5
5
  #include <ruby.h>
6
+ #include <ruby/version.h>
6
7
  #include <sqlfront.h>
7
8
  #include <sybdb.h>
8
9
  #include <syberror.h>
data/lib/tiny_tds.rb CHANGED
@@ -15,5 +15,5 @@ require 'tiny_tds/tiny_tds'
15
15
  #
16
16
  # Tiny Ruby Wrapper For FreeTDS Using DB-Library
17
17
  module TinyTds
18
- VERSION = '0.2.1'
18
+ VERSION = '0.2.2'
19
19
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_tds
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ken Collins
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-21 00:00:00 -04:00
19
+ date: 2010-10-26 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies: []
22
22