tiny_tds 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +5 -0
- data/README.rdoc +2 -2
- data/ext/tiny_tds/client.c +25 -2
- data/lib/tiny_tds.rb +1 -1
- data/lib/tiny_tds/client.rb +7 -11
- metadata +6 -6
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -15,7 +15,7 @@ The API is simple and consists of these classes:
|
|
15
15
|
|
16
16
|
== Install
|
17
17
|
|
18
|
-
Installing with rubygems should just work. TinyTds is tested on ruby version 1.8.6, 1.8.7, 1.9.1, 1.9.2 as well as REE.
|
18
|
+
Installing with rubygems should just work. TinyTds is tested on ruby version 1.8.6, 1.8.7, 1.9.1, 1.9.2 as well as REE & JRuby.
|
19
19
|
|
20
20
|
$ gem install tiny_tds
|
21
21
|
|
@@ -174,7 +174,7 @@ By default row caching is turned on because the SQL Server adapter for ActiveRec
|
|
174
174
|
|
175
175
|
|
176
176
|
|
177
|
-
== Using TinyTds With
|
177
|
+
== Using TinyTds With Rails & The ActiveRecord SQL Server adapter.
|
178
178
|
|
179
179
|
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.
|
180
180
|
|
data/ext/tiny_tds/client.c
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
VALUE cTinyTdsClient;
|
7
7
|
extern VALUE mTinyTds, cTinyTdsError;
|
8
|
+
static ID sym_username, sym_password, sym_dataserver, sym_database, sym_appname, sym_tds_version, sym_login_timeout, sym_timeout, sym_encoding;
|
8
9
|
static ID intern_source_eql, intern_severity_eql, intern_db_error_number_eql, intern_os_error_number_eql;
|
9
10
|
static ID intern_new, intern_dup, intern_transpose_iconv_encoding, intern_local_offset, intern_gsub;
|
10
11
|
VALUE opt_escape_regex, opt_escape_dblquote;
|
@@ -210,7 +211,19 @@ static VALUE rb_tinytds_return_code(VALUE self) {
|
|
210
211
|
|
211
212
|
// TinyTds::Client (protected)
|
212
213
|
|
213
|
-
static VALUE rb_tinytds_connect(VALUE self, VALUE
|
214
|
+
static VALUE rb_tinytds_connect(VALUE self, VALUE opts) {
|
215
|
+
/* Parsing options hash to local vars. */
|
216
|
+
VALUE user, pass, dataserver, database, app, version, ltimeout, timeout, charset;
|
217
|
+
user = rb_hash_aref(opts, sym_username);
|
218
|
+
pass = rb_hash_aref(opts, sym_password);
|
219
|
+
dataserver = rb_hash_aref(opts, sym_dataserver);
|
220
|
+
database = rb_hash_aref(opts, sym_database);
|
221
|
+
app = rb_hash_aref(opts, sym_appname);
|
222
|
+
version = rb_hash_aref(opts, sym_tds_version);
|
223
|
+
ltimeout = rb_hash_aref(opts, sym_login_timeout);
|
224
|
+
timeout = rb_hash_aref(opts, sym_timeout);
|
225
|
+
charset = rb_hash_aref(opts, sym_encoding);
|
226
|
+
/* Dealing with options. */
|
214
227
|
if (dbinit() == FAIL) {
|
215
228
|
rb_raise(cTinyTdsError, "failed dbinit() function");
|
216
229
|
return self;
|
@@ -265,7 +278,17 @@ void init_tinytds_client() {
|
|
265
278
|
rb_define_method(cTinyTdsClient, "escape", rb_tinytds_escape, 1);
|
266
279
|
rb_define_method(cTinyTdsClient, "return_code", rb_tinytds_return_code, 0);
|
267
280
|
/* Define TinyTds::Client Protected Methods */
|
268
|
-
rb_define_protected_method(cTinyTdsClient, "connect", rb_tinytds_connect,
|
281
|
+
rb_define_protected_method(cTinyTdsClient, "connect", rb_tinytds_connect, 1);
|
282
|
+
/* Symbols For Connect */
|
283
|
+
sym_username = ID2SYM(rb_intern("username"));
|
284
|
+
sym_password = ID2SYM(rb_intern("password"));
|
285
|
+
sym_dataserver = ID2SYM(rb_intern("dataserver"));
|
286
|
+
sym_database = ID2SYM(rb_intern("database"));
|
287
|
+
sym_appname = ID2SYM(rb_intern("appname"));
|
288
|
+
sym_tds_version = ID2SYM(rb_intern("tds_version"));
|
289
|
+
sym_login_timeout = ID2SYM(rb_intern("login_timeout"));
|
290
|
+
sym_timeout = ID2SYM(rb_intern("timeout"));
|
291
|
+
sym_encoding = ID2SYM(rb_intern("encoding"));
|
269
292
|
/* Intern TinyTds::Error Accessors */
|
270
293
|
intern_source_eql = rb_intern("source=");
|
271
294
|
intern_severity_eql = rb_intern("severity=");
|
data/lib/tiny_tds.rb
CHANGED
data/lib/tiny_tds/client.rb
CHANGED
@@ -47,18 +47,14 @@ module TinyTds
|
|
47
47
|
|
48
48
|
|
49
49
|
def initialize(opts={})
|
50
|
+
raise ArgumentError, 'missing :username option' if opts[:username].nil? || opts[:username].empty?
|
50
51
|
@query_options = @@default_query_options.dup
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
ltimeout = opts[:login_timeout] || 60
|
58
|
-
timeout = opts[:timeout] || 5
|
59
|
-
encoding = (opts[:encoding].nil? || opts[:encoding].downcase == 'utf8') ? 'UTF-8' : opts[:encoding].upcase
|
60
|
-
raise ArgumentError, 'missing :username option' if user.nil? || user.empty?
|
61
|
-
connect(user, pass, dataserver, database, appname, version, ltimeout, timeout, encoding)
|
52
|
+
opts[:appname] ||= 'TinyTds'
|
53
|
+
opts[:tds_version] = TDS_VERSIONS_SETTERS[opts[:tds_version].to_s] || TDS_VERSIONS_SETTERS['80']
|
54
|
+
opts[:login_timeout] ||= 60
|
55
|
+
opts[:timeout] ||= 5
|
56
|
+
opts[:encoding] = (opts[:encoding].nil? || opts[:encoding].downcase == 'utf8') ? 'UTF-8' : opts[:encoding].upcase
|
57
|
+
connect(opts)
|
62
58
|
end
|
63
59
|
|
64
60
|
def tds_version_info
|
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:
|
5
|
-
prerelease:
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.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: 2011-01-
|
19
|
+
date: 2011-01-17 00:00:00 -05:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
requirements: []
|
74
74
|
|
75
75
|
rubyforge_project:
|
76
|
-
rubygems_version: 1.
|
76
|
+
rubygems_version: 1.4.1
|
77
77
|
signing_key:
|
78
78
|
specification_version: 3
|
79
79
|
summary: TinyTds - A modern, simple and fast FreeTDS library for Ruby using DB-Library.
|