Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Work with tinytds 0.4.5

This removes the copying of the :host option to the :dataserver
option when using the tinytds adapter.  That worked fine for previous
versions of tiny_tds, but no longer works with 0.4.5.

This breaks backwards compatibility with previous connection urls
where the freetds.conf name was specified as the :host.  To use
an entry in the freetds.conf file, you must now provide the
:dataserver option.

Unfortunately, tinytds 0.4.5 does not work with FreeTDS 0.91rc1, you
have to use FreeTDS 0.91rc2 or an older version of FreeTDS such as
0.82 (and older versions require the use of the freetds.conf file).

Since 0.4.5 is now required, switch to using active? instead of
closed? and dead? to detect disconnects.
  • Loading branch information...
commit 2841832938b9734c5e0ff296f727fc70047a5c14 1 parent 41e72f3
Jeremy Evans authored June 28, 2011
2  CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 === HEAD
2 2
 
  3
+* Work with tiny_tds-0.4.5 in the tinytds adapter, older versions are no longer supported (jeremyevans)
  4
+
3 5
 * Make association_pks plugin typecast provided values to integer if the primary key column type is integer (jeremyevans)
4 6
  
5 7
 * Model.set_dataset now accepts Identifier, QualifiedIdentifier, and AliasedExpression arguments (jeremyevans)
13  doc/opening_databases.rdoc
Source Rendered
@@ -355,14 +355,17 @@ Examples:
355 355
 
356 356
 Because the underscore is not a valid character in a URI schema, the adapter
357 357
 is named tinytds instead of tiny_tds.  The connection options are passed directly
358  
-to tiny_tds, except that the tiny_tds :dataserver and :username options are set to
359  
-the Sequel :host and :user options.  The :host option should be an entry in the
360  
-freetds.conf file, it's not currently possible to a host not present in the
361  
-freetds.conf file.  Some options that you may want to set are
362  
-:login_timeout, :timeout, :appname, and :encoding, see the tiny_tds README for details.
  358
+to tiny_tds, except that the tiny_tds :username option is set to
  359
+the Sequel :user option.  If you want to use an entry in the freetds.conf file, you
  360
+should specify the :dataserver option with that name as the value.  Some other
  361
+options that you may want to set are :login_timeout, :timeout, :tds_version, :azure,
  362
+:appname, and :encoding, see the tiny_tds README for details.
  363
+
363 364
 For highest performance, you should disable any identifier output method when
364 365
 using the tinytds adapter, which probably means disabling any identifier input method
365 366
 as well.  The default for Microsoft SQL Server is to :downcase identifiers on output
366 367
 and :upcase them on input, so the highest performance will require changing the setting
367 368
 from the default.
368 369
 
  370
+The Sequel tinytds adapter requires tiny_tds >= 0.4.5, and if you are using FreeTDS
  371
+0.91, you must at least be using 0.91rc2 (0.91rc1 does not work).
3  lib/sequel/adapters/tinytds.rb
@@ -11,7 +11,6 @@ class Database < Sequel::Database
11 11
       # :dataserver and :username options.
12 12
       def connect(server)
13 13
         opts = server_opts(server)
14  
-        opts[:dataserver] = opts[:host]
15 14
         opts[:username] = opts[:user]
16 15
         set_mssql_unicode_strings
17 16
         TinyTds::Client.new(opts)
@@ -39,7 +38,7 @@ def execute(sql, opts={})
39 38
             end
40 39
             yield(r) if block_given?
41 40
           rescue TinyTds::Error => e
42  
-            raise_error(e, :disconnect=>(c.closed? || (c.respond_to?(:dead?) && c.dead?)))
  41
+            raise_error(e, :disconnect=>!c.active?)
43 42
           ensure
44 43
            r.cancel if r && c.sqlsent?
45 44
           end

0 notes on commit 2841832

Please sign in to comment.
Something went wrong with that request. Please try again.