tiny_tds 0.6.3.rc2-x64-mingw32 → 0.7.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c29e484a2a4c328fe243ca0785cdcae631c3a71d
4
- data.tar.gz: 0cf68711b030d483391270f2999f93154da28c51
3
+ metadata.gz: 257744e6c73a30b6f701f9b61e97202715ec0309
4
+ data.tar.gz: a276ae3a3fceff78f42eb53722da546d2ec359a0
5
5
  SHA512:
6
- metadata.gz: 84a8426b4b18cc074eab7b78f833f93644c0f73cd10c2774085f1d13061f22be5ef0a44fd8e0110257bd4c83e795eab40212259c52da2fc38e4ed8bc5886e387
7
- data.tar.gz: b233d8744fb80fbc3180dc7a86dd5ddf2cf87248eafc340a80257b25fd7e97faf4ead4f5bdd350faf0010a021ba1e64ef671ef51850201c40f4a640bd4f7746e
6
+ metadata.gz: 787b48162251c70224cef85506cd6a9ec2d6874ab2d319c42fffdec82d374dda977e5c1fec6c1cb0d8ca185d25047b4a9f7133a1848262d16cf9438b3d255cb3
7
+ data.tar.gz: f936d9f73d37f813013c059d0e1fdd6239d30373d2db8934f6c1a89fcc2c283d7a95e6358f0add257eb0641ab36731933915cd1ee4210da0a87ead44d3a554fe
data/CHANGELOG CHANGED
@@ -1,5 +1,7 @@
1
1
 
2
- * 0.6.3.rc1 *
2
+ * 0.7.0 *
3
+
4
+ * Refactor build of FreeTDS & Iconv recipes. Add OpenSSL. Merged #207.
3
5
 
4
6
  * Ensure zero terminated strings, where C-str pointers are expected. Use StringValueCStr() Fixes #208.
5
7
 
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
- # TinyTDS - A modern, simple and fast FreeTDS library for Ruby using DB-Library.
1
+ # TinyTDS - Simple and fast FreeTDS bindings for Ruby using DB-Library.
2
2
 
3
- The TinyTDS gem is meant to serve the extremely common use-case of connecting, querying and iterating over results to Microsoft SQL Server databases from ruby. Even though it uses FreeTDS's DB-Library, it is NOT meant to serve as direct 1:1 mapping of that C API.
3
+ [![Build Status](https://ci.appveyor.com/api/projects/status/g2bhhbsdkx0mal55/branch/master?svg=true)](https://ci.appveyor.com/project/rails-sqlserver/tiny-tds/branch/master) [![Gem Version](https://img.shields.io/badge/gem-v0.7.0-blue.svg)](https://rubygems.org/gems/tiny_tds)
4
4
 
5
- The benefits are speed, automatic casting to ruby primitives, and proper encoding support. It converts all SQL Server datatypes to native ruby objects supporting :utc or :local time zones for time-like types. To date it is the only ruby client library that allows client encoding options, defaulting to UTF-8, while connecting to SQL Server. It also properly encodes all string and binary data. The motivation for TinyTDS is to become the de-facto low level connection mode for the SQL Server adapter for ActiveRecord. For further details see the special thanks section at the bottom
5
+
6
+ The TinyTDS gem is meant to serve the extremely common use-case of connecting, querying and iterating over results to Microsoft SQL Server or Sybase databases from Ruby using the FreeTDS's DB-Library API.
7
+
8
+ TinyTDS offers automatic casting to Ruby primitives along with proper encoding support. It converts all SQL Server datatypes to native Ruby primitives while supporting :utc or :local time zones for time-like types. To date it is the only Ruby client library that allows client encoding options, defaulting to UTF-8, while connecting to SQL Server. It also properly encodes all string and binary data. The motivation for TinyTDS is to become the de-facto low level connection mode for the SQL Server Adapter for ActiveRecord.
6
9
 
7
10
  The API is simple and consists of these classes:
8
11
 
@@ -13,18 +16,37 @@ The API is simple and consists of these classes:
13
16
 
14
17
  ## Install
15
18
 
16
- Installing with rubygems should just work. TinyTDS is currently tested on Ruby version 1.9.3 and upward. Older versions are tested with Ruby 1.8 and lower. If you are using Ruby 1.8, please use v0.6.0.rc1 or lower. The v0.6.0 release and higher are only compatible with Ruby 1.9.3 (or higher).
19
+ Installing with rubygems should just work. TinyTDS is currently tested on Ruby version 1.9.3 and upward.
17
20
 
18
21
  ```
19
22
  $ gem install tiny_tds
20
23
  ```
21
24
 
22
- Although we search for FreeTDS's libraries and headers, you may have to specify include and lib directories using `--with-freetds-include=/some/local/include/freetds` and `--with-freetds-lib=/some/local/lib`
25
+ If you use Windows, we pre-compile TinyTDS with static versions of FreeTDS, libiconv, and OpenSSL. On all other platforms, we will find these dependencies. If none exist, our native extension will use MiniPortile to install any missing dependencies listed above for your specific platform. These dependencies will be built and linked within the installed TinyTDS gem. Please read the MiniPortile and/or Windows sections at the end of this file for advanced configuration options past the following:
26
+
27
+ ```
28
+ --enable-system-freetds / --disable-system-freetds
29
+ --enable-system-iconv / --disable-system-iconv
30
+ --enable-system-openssl / --disable-system-openssl
31
+ Force use of system or builtin freetds/iconv/openssl library.
32
+ Default is to prefer system libraries and fallback to builtin.
33
+
34
+ --with-freetds-dir=DIR
35
+ Use the freetds library placed under DIR.
36
+
37
+ --enable-lookup
38
+ Search for freetds through all paths in the PATH environment variable.
39
+
40
+ --enable-cross-build
41
+ Do cross-build.
42
+ ```
23
43
 
24
44
 
25
45
  ## FreeTDS Compatibility & Configuration
26
46
 
27
- TinyTDS is developed against FreeTDS 0.82 & 0.91, and 0.92 currents, the latest is recommended. It is tested with SQL Server 2000, 2005, 2008, 2014, and Azure. Below are a few QA style notes about installing FreeTDS.
47
+ TinyTDS is developed against FreeTDS 0.82, 0.91 stable, and 0.92 current. Our default and recommended is 0.91 stable. We also test with SQL Server 2000, 2005, 2008, 2014, and Azure. Below are a few QA style notes about installing FreeTDS.
48
+
49
+ **NOTE:** Windows users of our pre-compiled native gems need not worry about installing FreeTDS and its dependencies.
28
50
 
29
51
  * **Do I need to install FreeTDS?** Yes! Somehow, someway, you are going to need FreeTDS for TinyTDS to compile against. You can avoid installing FreeTDS on your system by using our projects usage of rake-compiler and mini_portile to compile and package a native gem just for you. See the "Using MiniPortile" section below.
30
52
 
@@ -39,9 +61,9 @@ TinyTDS is developed against FreeTDS 0.82 & 0.91, and 0.92 currents, the latest
39
61
 
40
62
  ## Data Types
41
63
 
42
- Our goal is to support every SQL Server data type and covert it to a logical ruby object. When dates or times are returned, they are instantiated to either `:utc` or `:local` time depending on the query options. Under ruby 1.9, all strings are encoded to the connection's encoding and all binary data types are associated to ruby's `ASCII-8BIT/BINARY` encoding.
64
+ Our goal is to support every SQL Server data type and covert it to a logical Ruby object. When dates or times are returned, they are instantiated to either `:utc` or `:local` time depending on the query options. All strings are associated the to the connection's encoding and all binary data types are associated to Ruby's `ASCII-8BIT/BINARY` encoding.
43
65
 
44
- Below is a list of the data types we plan to support using future versions of FreeTDS. They are associated with SQL Server 2008 and up. All unsupported data types are returned as properly encoded strings.
66
+ Below is a list of the data types we plan to support using future versions of FreeTDS. They are associated with SQL Server 2008 and up. All unsupported data types below are returned as strings.
45
67
 
46
68
  * [date]
47
69
  * [datetime2]
@@ -110,7 +132,7 @@ Calling #each on the result will lazily load each row from the database.
110
132
  result.each do |row|
111
133
  # By default each row is a hash.
112
134
  # The keys are the fields, as you'd expect.
113
- # The values are pre-built ruby primitives mapped from their corresponding types.
135
+ # The values are pre-built Ruby primitives mapped from their corresponding types.
114
136
  end
115
137
  ```
116
138
 
@@ -227,7 +249,7 @@ Every `TinyTds::Result` object can pass query options to the #each method. The d
227
249
  * :as => :hash - Object for each row yielded. Can be set to :array.
228
250
  * :symbolize_keys => false - Row hash keys. Defaults to shared/frozen string keys.
229
251
  * :cache_rows => true - Successive calls to #each returns the cached rows.
230
- * :timezone => :local - Local to the ruby client or :utc for UTC.
252
+ * :timezone => :local - Local to the Ruby client or :utc for UTC.
231
253
  * :empty_sets => true - Include empty results set in queries that return multiple result sets.
232
254
 
233
255
  Each result gets a copy of the default options you specify at the client level and can be overridden by passing an options hash to the #each method. For example
@@ -254,15 +276,14 @@ By default row caching is turned on because the SQL Server adapter for ActiveRec
254
276
 
255
277
  ## Encoding Error Handling
256
278
 
257
- TinyTDS takes an opinionated stance on how we handle encoding errors. First, we treat errors differently on reads vs. writes. Our opinion is that if you are reading bad data due to your client's encoding option, you would rather just find `?`'marks in your strings vs being blocked with exceptions. This is how things wold work via ODBC or SMS. On the other hand, writes will raise an exception. In this case we raise the SYBEICONVO/2402 error message which has a description of `Error converting characters into server's character set. Some character(s) could not be converted.`. Even though the severity of this message is only a `4` and TinyTDS will automatically strip/ignore unknown characters, we feel you should know that you are inserting bad encodings. In this way, a transaction can be rolled back, etc. Remember, any database write that has bad characters due to the client encoding will still be written to the database, but it is up to you rollback said write if needed. Most ORMs like ActiveRecord handle this scenario just fine.
279
+ TinyTDS takes an opinionated stance on how we handle encoding errors. First, we treat errors differently on reads vs. writes. Our opinion is that if you are reading bad data due to your client's encoding option, you would rather just find `?` marks in your strings vs being blocked with exceptions. This is how things wold work via ODBC or SMS. On the other hand, writes will raise an exception. In this case we raise the SYBEICONVO/2402 error message which has a description of `Error converting characters into server's character set. Some character(s) could not be converted.`. Even though the severity of this message is only a `4` and TinyTDS will automatically strip/ignore unknown characters, we feel you should know that you are inserting bad encodings. In this way, a transaction can be rolled back, etc. Remember, any database write that has bad characters due to the client encoding will still be written to the database, but it is up to you rollback said write if needed. Most ORMs like ActiveRecord handle this scenario just fine.
258
280
 
259
281
 
260
282
  ## Using TinyTDS With Rails & The ActiveRecord SQL Server adapter.
261
283
 
262
- 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, this is the default in versions 3.1 or higher. 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.
284
+ TinyTDS is the default connection mode for the SQL Server adapter in versions 3.1 or higher. The SQL Server adapter can be found using the links below.
263
285
 
264
286
  * ActiveRecord SQL Server Adapter: http://github.com/rails-sqlserver/activerecord-sqlserver-adapter
265
- * Using TinyTDS: http://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Using-TinyTds
266
287
 
267
288
 
268
289
  ## Using TinyTDS with Azure
@@ -288,29 +309,14 @@ Also, please read the [Azure SQL Database General Guidelines and Limitations](ht
288
309
 
289
310
  ## Using MiniPortile
290
311
 
291
- MiniPortile is a minimalistic, simplistic and stupid implementation of a port/recipe system for developers. <https://github.com/luislavena/mini_portile>
292
-
293
- The TinyTDS project uses MiniPortile so that we can easily install a local "project specific" version of FreeTDS and supporting libraries to link against when building a test version of TinyTDS. MiniPortile is a great tool that even allows us to build statically linked components that TinyTDS relies on. Hence this allows us to publish native gems for any platform. We use this feature for gems targeted at Windows.
294
-
295
- You too can use MiniPortile to build TinyTDS and build your own gems for your own package management needs. Here is a few simple steps that assume you have cloned a fresh copy of this repository. 1) Bundling will install all the development dependencies. 2) Running `rake compile` will basically download and install a supported version of FreeTDS in our `ports.rake` file and supporting libraries. These will all be installed into the projects tmp directory. 3) The final `rake native gem` command will build a native gem for your specific platform. 4) The native gem can be found in the `pkg` directory. The last command assumes "X" is version numbers and #{platform} will be your platform. Note that if you're using Windows make sure you are running these rake tasks with a Unix-style command line tool like [MSYS](http://www.mingw.org/wiki/MSYS).
312
+ MiniPortile is a minimalistic implementation of a port/recipe system. <https://github.com/luislavena/mini_portile>
296
313
 
297
- ```
298
- $ bundle install
299
- $ rake compile
300
- $ rake native gem
301
- $ gem install pkg/tiny_tds-X.X.X-#{platform}.gem
302
- ```
303
-
304
- **Important:** You must use rubygems version 1.7.2 or higher. You will almost certainly hit a *Don't know how to build task...* error when running the `rake native gem` command if you do not. Please update rubygems! Here is a link on [how to upgrade or downgrade rubygems](http://rubygems.rubyforge.org/rubygems-update/UPGRADING_rdoc.html).
305
-
306
- It is also possible to build a specific version of FreeTDS for your own gem or development and testing using the `TINYTDS_FREETDS_VERSION` environment variable. Here are some exampbles of possible values.
314
+ The TinyTDS project uses MiniPortile so that we can easily install a local version of FreeTDS and supporting libraries to link against when building a test version of TinyTDS. This same system is also used when installing TinyTDS with Rubygems and building native extensions. It is possible to build TinyTDS with a specific version of FreeTDS using the `TINYTDS_FREETDS_VERSION` environment variable. Here are some exampbles of possible values.
307
315
 
308
316
  ```
309
- $ rake TINYTDS_FREETDS_VERSION="0.82"
310
- $ rake TINYTDS_FREETDS_VERSION="0.91"
311
- $ rake TINYTDS_FREETDS_VERSION="0.91.89"
312
- $ rake TINYTDS_FREETDS_VERSION="0.92.405"
313
- $ rake TINYTDS_FREETDS_VERSION="current"
317
+ $ rake TINYTDS_FREETDS_VERSION='0.82' -- --disable-system-freetds --disable-system-iconv
318
+ $ rake TINYTDS_FREETDS_VERSION='0.91' -- --disable-system-freetds --disable-system-iconv
319
+ $ rake TINYTDS_FREETDS_VERSION='0.92' -- --disable-system-freetds --disable-system-iconv
314
320
  ```
315
321
 
316
322
  To find out more about the FreeTDS release system [visit this thread](http://lists.ibiblio.org/pipermail/freetds/2012q1/027756.html) on their mailing list. You can also browse thier FTP server [ftp://ftp.astron.com/pub/freetds/](ftp://ftp.astron.com/pub/freetds/) for version number strings.
@@ -318,20 +324,34 @@ To find out more about the FreeTDS release system [visit this thread](http://lis
318
324
 
319
325
  ## Compiling Gems for Windows
320
326
 
321
- For the convenience of Windows users, TinyTDS ships pre-compiled for Ruby 1.9.3, 2.0, 2.1 and 2.2 on Windows. In order to generate these gems, [rake-compiler-dock](https://github.com/rake-compiler/rake-compiler-dock) is used. This project provides a [Docker image](https://registry.hub.docker.com/u/larskanis/rake-compiler-dock/) with rvm, cross-compilers and a number of different target versions of ruby.
327
+ For the convenience of Windows users, TinyTDS ships pre-compiled gems for Ruby 1.9.3, 2.0, 2.1 and 2.2 on Windows. In order to generate these gems, [rake-compiler-dock](https://github.com/rake-compiler/rake-compiler-dock) is used. This project provides a [Docker image](https://registry.hub.docker.com/u/larskanis/rake-compiler-dock/) with rvm, cross-compilers and a number of different target versions of Ruby.
322
328
 
323
- Run the following rake task to compile the gem for Windows. This will check the availability of [Docker](https://www.docker.com/) (and boot2docker on Windows or OS-X) and will give some advice for download and installation. When docker is running, it will download the docker image (once-only) and start the build:
329
+ Run the following rake task to compile the gems for Windows. This will check the availability of [Docker](https://www.docker.com/) (and boot2docker on Windows or OS-X) and will give some advice for download and installation. When docker is running, it will download the docker image (once-only) and start the build:
324
330
 
325
331
  ```
326
332
  $ rake gem:windows
327
333
  ```
328
334
 
329
- The compiled gems will exist in `./pkg/`.
335
+ The compiled gems will exist in `./pkg` directory.
330
336
 
331
337
 
332
338
  ## Development & Testing
333
339
 
334
- We use bundler for development. Simply run `bundle install` then `rake` to build the gem and run the unit tests. The tests assume you have created a database named `tinytdstest` accessible by a database owner named `tinytds`. Before running the test rake task, you may need to define a pair of environment variables that help the client connect to your specific FreeTDS database server name and which schema (2000, 2005, 2008, 2014, Azure or Sybase ASE) to use. For example:
340
+ First make sure your local database has a `[tinytdstest]` database with a owner login named `[tinytds]` having no password. The following SQL run via the `sa` account should set that up for you.
341
+
342
+ ```sql
343
+ CREATE DATABASE [tinytdstest];
344
+ GO
345
+ CREATE LOGIN [tinytds] WITH PASSWORD = '', CHECK_POLICY = OFF, DEFAULT_DATABASE = [tinytdstest];
346
+ GO
347
+ USE [tinytdstest];
348
+ CREATE USER [tinytds] FOR LOGIN [tinytds];
349
+ GO
350
+ EXEC sp_addrolemember N'db_owner', N'tinytds';
351
+ GO
352
+ ```
353
+
354
+ We use bundler for development. Simply run `bundle install` then `rake` to build the gem and run the unit tests. Before running the test rake task, you may need to define a pair of environment variables that help the client connect to your specific FreeTDS database server name and which schema (2000, 2005, 2008, 2014, Azure or Sybase ASE) to use. For example:
335
355
 
336
356
  ```
337
357
  $ rake TINYTDS_UNIT_DATASERVER=mydbserver
@@ -358,26 +378,21 @@ $ rake TINYTDS_SKIP_PORTS=1
358
378
  * IRC Room: #rails-sqlserver on irc.freenode.net
359
379
 
360
380
 
361
- ## TODO List
362
-
363
- * Install an interrupt handler.
364
- * Allow #escape to accept all ruby primitives.
365
-
366
-
367
381
  ## About Me
368
382
 
369
- My name is Ken Collins and I currently maintain the SQL Server adapter for ActiveRecord and wrote this library as my first cut into learning ruby C extensions. Hopefully it will help promote the power of ruby and the Rails framework to those that have not yet discovered it. My blog is [metaskills.net](http://metaskills.net/) and I can be found on twitter as @metaskills. Enjoy!
383
+ My name is Ken Collins and I currently maintain the SQL Server adapter for ActiveRecord and wrote this library as my first cut into learning Ruby C extensions. Hopefully it will help promote the power of Ruby and the Rails framework to those that have not yet discovered it. My blog is [metaskills.net](http://metaskills.net/) and I can be found on twitter as @metaskills. Enjoy!
370
384
 
371
385
 
372
386
  ## Special Thanks
373
387
 
388
+ * Lars Kanis for all his help getting the Windows builds working again with rake-compiler-dock.
374
389
  * Erik Bryn for joining the project and helping me thru a few tight spots. - http://github.com/ebryn
375
390
  * To the authors and contributors of the Mysql2 gem for inspiration. - http://github.com/brianmario/mysql2
376
- * Yehuda Katz for articulating ruby's need for proper encoding support. Especially in database drivers - http://yehudakatz.com/2010/05/05/ruby-1-9-encodings-a-primer-and-the-solution-for-rails/
377
- * Josh Clayton of Thoughtbot for writing about ruby C extensions. - http://robots.thoughtbot.com/post/1037240922/get-your-c-on
391
+ * Yehuda Katz for articulating Ruby's need for proper encoding support. Especially in database drivers - http://yehudakatz.com/2010/05/05/ruby-1-9-encodings-a-primer-and-the-solution-for-rails/
392
+ * Josh Clayton of Thoughtbot for writing about Ruby C extensions. - http://robots.thoughtbot.com/post/1037240922/get-your-c-on
378
393
 
379
394
 
380
395
  ## License
381
396
 
382
- TinyTDS is Copyright (c) 2010-2015 Ken Collins, <ken@metaskills.net> and Will Bond (Veracross LLC) <wbond@breuer.com>. It is distributed under the MIT license. Windows binaries contain precompiled versions of FreeTDS <http://www.freetds.org/> which is licensed under the GNU LGPL license at <http://www.gnu.org/licenses/lgpl-2.0.html>
397
+ TinyTDS is Copyright (c) 2010-2015 Ken Collins, <ken@metaskills.net> and Will Bond (Veracross LLC) <wbond@breuer.com>. It is distributed under the MIT license. Windows binaries contain pre-compiled versions of FreeTDS <http://www.freetds.org/> which is licensed under the GNU LGPL license at <http://www.gnu.org/licenses/lgpl-2.0.html>
383
398
 
data/appveyor.yml CHANGED
@@ -1,48 +1,42 @@
1
- services:
2
- - mssql2014
3
-
4
- install:
1
+ version: 0.7.0.{build}
2
+ init:
5
3
  - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
6
4
  - SET PATH=C:\MinGW\msys\1.0\bin;%PATH%
7
5
  - SET RAKEOPT=-rdevkit
8
- - SET TINYTDS_UNIT_DATASERVER=localhost\SQL2014
9
- - SET TINYTDS_UNIT_DATABASE=master
10
- - SET TINYTDS_UNIT_USER=sa
11
- - SET TINYTDS_UNIT_PASS=Password12!
6
+ clone_depth: 5
7
+ skip_tags: true
8
+ matrix:
9
+ fast_finish: true
10
+ install:
12
11
  - ruby --version
13
12
  - gem --version
14
13
  - bundle install
15
- - ps: |
16
- [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null
17
- [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SqlWmiManagement") | Out-Null
18
-
19
- $serverName = $env:COMPUTERNAME
20
- $instanceName = 'SQL2014'
21
- $smo = 'Microsoft.SqlServer.Management.Smo.'
22
- $wmi = new-object ($smo + 'Wmi.ManagedComputer')
23
-
24
- # Enable TCP/IP
25
- $uri = "ManagedComputer[@Name='$serverName']/ServerInstance[@Name='$instanceName']/ServerProtocol[@Name='Tcp']"
26
- $Tcp = $wmi.GetSmoObject($uri)
27
- $Tcp.IsEnabled = $true
28
- $TCP.alter()
29
-
30
- # Start services
31
- Set-Service SQLBrowser -StartupType Manual
32
- Start-Service SQLBrowser
33
- Start-Service "MSSQL`$$instanceName"
34
-
14
+ - bundle exec rake build
35
15
  build: off
36
-
37
16
  test_script:
38
- - bundle exec rake
39
-
17
+ - timeout /t 4 /nobreak > NUL
18
+ - powershell -File "%APPVEYOR_BUILD_FOLDER%\test\appveyor\dbsetup.ps1"
19
+ - timeout /t 4 /nobreak > NUL
20
+ - ps: Start-Service 'MSSQL$SQL2014'
21
+ - timeout /t 4 /nobreak > NUL
22
+ - sqlcmd -S ".\SQL2014" -U sa -P Password12! -i %APPVEYOR_BUILD_FOLDER%\test\appveyor\dbsetup.sql
23
+ - bundle exec rake TINYTDS_UNIT_HOST_TEST=localhost TINYTDS_UNIT_DATASERVER="localhost\SQL2014" TINYTDS_SCHEMA=sqlserver_2014
24
+ - ps: Stop-Service 'MSSQL$SQL2014'
25
+ - ps: Start-Service 'MSSQL$SQL2012SP1'
26
+ - timeout /t 4 /nobreak > NUL
27
+ - sqlcmd -S ".\SQL2012SP1" -U sa -P Password12! -i %APPVEYOR_BUILD_FOLDER%\test\appveyor\dbsetup.sql
28
+ - bundle exec rake TINYTDS_UNIT_HOST_TEST=localhost TINYTDS_UNIT_DATASERVER="localhost\SQL2012SP1" TINYTDS_SCHEMA=sqlserver_2014
29
+ - ps: Stop-Service 'MSSQL$SQL2012SP1'
30
+ - ps: Start-Service 'MSSQL$SQL2008R2SP2'
31
+ - timeout /t 4 /nobreak > NUL
32
+ - sqlcmd -S ".\SQL2008R2SP2" -U sa -P Password12! -i %APPVEYOR_BUILD_FOLDER%\test\appveyor\dbsetup.sql
33
+ - bundle exec rake TINYTDS_UNIT_HOST_TEST=localhost TINYTDS_UNIT_DATASERVER="localhost\SQL2008R2SP2" TINYTDS_SCHEMA=sqlserver_2008
40
34
  environment:
41
35
  matrix:
42
36
  - ruby_version: "193"
43
- #- ruby_version: "200"
44
- #- ruby_version: "200-x64"
45
- #- ruby_version: "21"
46
- #- ruby_version: "21-x64"
47
- #- ruby_version: "22"
37
+ - ruby_version: "200"
38
+ - ruby_version: "200-x64"
39
+ - ruby_version: "21"
40
+ - ruby_version: "21-x64"
41
+ - ruby_version: "22"
48
42
  - ruby_version: "22-x64"
@@ -26,7 +26,7 @@ VALUE opt_escape_regex, opt_escape_dblquote;
26
26
 
27
27
  VALUE rb_tinytds_raise_error(DBPROCESS *dbproc, int cancel, char *error, char *source, int severity, int dberr, int oserr) {
28
28
  GET_CLIENT_USERDATA(dbproc);
29
- if (cancel && !dbdead(dbproc) && userdata && !userdata->closed) {
29
+ if (cancel && !dbdead(dbproc) && userdata && !userdata->closed) {
30
30
  userdata->dbsqlok_sent = 1;
31
31
  dbsqlok(dbproc);
32
32
  userdata->dbcancel_sent = 1;
@@ -39,7 +39,7 @@ VALUE rb_tinytds_raise_error(DBPROCESS *dbproc, int cancel, char *error, char *s
39
39
  if (dberr)
40
40
  rb_funcall(e, intern_db_error_number_eql, 1, INT2FIX(dberr));
41
41
  if (oserr)
42
- rb_funcall(e, intern_os_error_number_eql, 1, INT2FIX(oserr));
42
+ rb_funcall(e, intern_os_error_number_eql, 1, INT2FIX(oserr));
43
43
  rb_exc_raise(e);
44
44
  return Qnil;
45
45
  }
@@ -47,7 +47,7 @@ VALUE rb_tinytds_raise_error(DBPROCESS *dbproc, int cancel, char *error, char *s
47
47
 
48
48
  // Lib Backend (Memory Management & Handlers)
49
49
 
50
- int tinytds_err_handler(DBPROCESS *dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) {
50
+ int tinytds_err_handler(DBPROCESS *dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) {
51
51
  static char *source = "error";
52
52
  GET_CLIENT_USERDATA(dbproc);
53
53
 
@@ -187,12 +187,12 @@ static VALUE allocate(VALUE klass) {
187
187
  cwrap->charset = Qnil;
188
188
  cwrap->userdata = malloc(sizeof(tinytds_client_userdata));
189
189
  cwrap->userdata->closed = 1;
190
- rb_tinytds_client_reset_userdata(cwrap->userdata);
190
+ rb_tinytds_client_reset_userdata(cwrap->userdata);
191
191
  return obj;
192
192
  }
193
193
 
194
194
 
195
- // TinyTds::Client (public)
195
+ // TinyTds::Client (public)
196
196
 
197
197
  static VALUE rb_tinytds_tds_version(VALUE self) {
198
198
  GET_CLIENT_WRAPPER(self);
@@ -244,7 +244,7 @@ static VALUE rb_tinytds_execute(VALUE self, VALUE sql) {
244
244
  GET_RESULT_WRAPPER(result);
245
245
  rwrap->local_offset = rb_funcall(cTinyTdsClient, intern_local_offset, 0);
246
246
  rwrap->encoding = cwrap->encoding;
247
- return result;
247
+ return result;
248
248
  }
249
249
 
250
250
  static VALUE rb_tinytds_charset(VALUE self) {
@@ -289,7 +289,7 @@ static VALUE rb_tinytds_freetds_nine_one_or_higher(VALUE self) {
289
289
  }
290
290
 
291
291
 
292
- // TinyTds::Client (protected)
292
+ // TinyTds::Client (protected)
293
293
 
294
294
  static VALUE rb_tinytds_connect(VALUE self, VALUE opts) {
295
295
  /* Parsing options hash to local vars. */
@@ -20,6 +20,7 @@ FREETDS_VERSION_INFO = Hash.new { |h,k|
20
20
  }.merge({
21
21
  "0.82" => {:files => "ftp://ftp.freetds.org/pub/freetds/old/0.82/freetds-0.82.tar.gz"},
22
22
  "0.91" => {:files => "ftp://ftp.freetds.org/pub/freetds/stable/freetds-0.91.112.tar.gz"},
23
+ "0.92" => {:files => "ftp://ftp.freetds.org/pub/freetds/stable/freetds-0.92.405.tar.gz"},
23
24
  "current" => {:files => "ftp://ftp.freetds.org/pub/freetds/current/freetds-current.tar.gz"}
24
25
  })
25
26
  FREETDS_SOURCE_URI = FREETDS_VERSION_INFO[FREETDS_VERSION][:files]
@@ -32,19 +33,19 @@ def do_help
32
33
  usage: ruby #{$0} [options]
33
34
 
34
35
  --enable-system-freetds / --disable-system-freetds
35
- --enable-system-iconv / --disable-system-iconv
36
+ --enable-system-iconv / --disable-system-iconv
36
37
  --enable-system-openssl / --disable-system-openssl
37
- Force use of system or builtin freetds/iconv/openssl library.
38
- Default is to prefer system libraries and fallback to builtin.
38
+ Force use of system or builtin freetds/iconv/openssl library.
39
+ Default is to prefer system libraries and fallback to builtin.
39
40
 
40
41
  --with-freetds-dir=DIR
41
- Use the freetds library placed under DIR.
42
+ Use the freetds library placed under DIR.
42
43
 
43
44
  --enable-lookup
44
- Search for freetds through all paths in the PATH environment variable.
45
+ Search for freetds through all paths in the PATH environment variable.
45
46
 
46
47
  --enable-cross-build
47
- Do cross-build.
48
+ Do cross-build.
48
49
  HELP
49
50
  exit! 0
50
51
  end
data/lib/tiny_tds.rb CHANGED
@@ -31,7 +31,12 @@ else
31
31
  ports_libs = File.expand_path("../../ports/#{RbConfig::CONFIG["host"]}/lib/*.so", __FILE__)
32
32
  Dir[ports_libs].each do |lib|
33
33
  require "fiddle"
34
- Fiddle.dlopen(lib)
34
+ if Fiddle.respond_to?(:dlopen)
35
+ Fiddle.dlopen(lib)
36
+ else
37
+ # For compat with Ruby < 2.0
38
+ DL.dlopen(lib)
39
+ end
35
40
  end
36
41
 
37
42
  require 'tiny_tds/tiny_tds'
@@ -1,22 +1,8 @@
1
- module TinyTds
1
+ module TinyTds
2
2
  class Error < StandardError
3
-
4
- SEVERITIES = [
5
- {:number => 1, :severity => 'EXINFO', :explanation => 'Informational, non-error.'},
6
- {:number => 2, :severity => 'EXUSER', :explanation => 'User error.'},
7
- {:number => 3, :severity => 'EXNONFATAL', :explanation => 'Non-fatal error.'},
8
- {:number => 4, :severity => 'EXCONVERSION', :explanation => 'Error in DB-Library data conversion.'},
9
- {:number => 5, :severity => 'EXSERVER', :explanation => 'The Server has returned an error flag.'},
10
- {:number => 6, :severity => 'EXTIME', :explanation => 'We have exceeded our timeout period while waiting for a response from the Server - the DBPROCESS is still alive.'},
11
- {:number => 7, :severity => 'EXPROGRAM', :explanation => 'Coding error in user program.'},
12
- {:number => 8, :severity => 'EXRESOURCE', :explanation => 'Running out of resources - the DBPROCESS may be dead.'},
13
- {:number => 9, :severity => 'EXCOMM', :explanation => 'Failure in communication with Server - the DBPROCESS is dead.'},
14
- {:number => 10, :severity => 'EXFATAL', :explanation => 'Fatal error - the DBPROCESS is dead.'},
15
- {:number => 11, :severity => 'EXCONSISTENCY', :explanation => 'Internal software error - notify Sybase Technical Support.'}
16
- ].freeze
17
-
3
+
18
4
  attr_accessor :source, :severity, :db_error_number, :os_error_number
19
-
5
+
20
6
  def initialize(message)
21
7
  super
22
8
  @severity = nil
@@ -1,3 +1,3 @@
1
1
  module TinyTds
2
- VERSION = '0.6.3.rc2'
2
+ VERSION = '0.7.0'
3
3
  end
@@ -0,0 +1,27 @@
1
+
2
+ Write-Output "Setting up..."
3
+ [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null
4
+ [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.SqlWmiManagement") | Out-Null
5
+
6
+ Write-Output "Setting variables..."
7
+ $serverName = $env:COMPUTERNAME
8
+ $instances = @('SQL2008R2SP2', 'SQL2012SP1', 'SQL2014')
9
+ $smo = 'Microsoft.SqlServer.Management.Smo.'
10
+ $wmi = new-object ($smo + 'Wmi.ManagedComputer')
11
+
12
+ Write-Output "Configure Instances..."
13
+ foreach ($instance in $instances) {
14
+ Write-Output "Instance $instance ..."
15
+ Write-Output "Enable TCP/IP and port 1433..."
16
+ $uri = "ManagedComputer[@Name='$serverName']/ServerInstance[@Name='$instance']/ServerProtocol[@Name='Tcp']"
17
+ $tcp = $wmi.GetSmoObject($uri)
18
+ $tcp.IsEnabled = $true
19
+ foreach ($ipAddress in $Tcp.IPAddresses) {
20
+ $ipAddress.IPAddressProperties["TcpDynamicPorts"].Value = ""
21
+ $ipAddress.IPAddressProperties["TcpPort"].Value = "1433"
22
+ }
23
+ $tcp.Alter()
24
+ }
25
+
26
+ Set-Service SQLBrowser -StartupType Manual
27
+ Start-Service SQLBrowser
@@ -0,0 +1,9 @@
1
+ CREATE DATABASE [tinytdstest];
2
+ GO
3
+ CREATE LOGIN [tinytds] WITH PASSWORD = '', CHECK_POLICY = OFF, DEFAULT_DATABASE = [tinytdstest];
4
+ GO
5
+ USE [tinytdstest];
6
+ CREATE USER [tinytds] FOR LOGIN [tinytds];
7
+ GO
8
+ EXEC sp_addrolemember N'db_owner', N'tinytds';
9
+ GO
data/test/client_test.rb CHANGED
@@ -52,7 +52,9 @@ class ClientTest < TinyTds::TestCase
52
52
  end
53
53
 
54
54
  it 'must be able to use :host/:port connection' do
55
- client = new_connection :dataserver => nil, :host => ENV['TINYTDS_UNIT_HOST'], :port => ENV['TINYTDS_UNIT_PORT'] || 1433
55
+ host = ENV['TINYTDS_UNIT_HOST_TEST'] || ENV['TINYTDS_UNIT_HOST']
56
+ port = ENV['TINYTDS_UNIT_PORT_TEST'] || ENV['TINYTDS_UNIT_PORT'] || 1433
57
+ client = new_connection dataserver: nil, host: host, port: port
56
58
  end unless sqlserver_azure?
57
59
 
58
60
  end
@@ -68,12 +70,12 @@ class ClientTest < TinyTds::TestCase
68
70
  end
69
71
 
70
72
  it 'raises TinyTds exception with undefined :dataserver' do
71
- options = connection_options :login_timeout => 1, :dataserver => '127.0.0.2'
73
+ options = connection_options :login_timeout => 1, :dataserver => 'DOESNOTEXIST'
72
74
  action = lambda { new_connection(options) }
73
75
  assert_raise_tinytds_error(action) do |e|
74
- assert [20008,20009].include?(e.db_error_number)
75
- assert_equal 9, e.severity
76
- assert_match %r{unable to (open|connect)}i, e.message, 'ignore if non-english test run'
76
+ assert_equal 20012, e.db_error_number
77
+ assert_equal 2, e.severity
78
+ assert_match %r{server name not found in configuration files}i, e.message, 'ignore if non-english test run'
77
79
  end
78
80
  assert_new_connections_work
79
81
  end
data/test/result_test.rb CHANGED
@@ -554,7 +554,7 @@ class ResultTest < TinyTds::TestCase
554
554
 
555
555
  let(:backup_file) { 'C:\\Users\\Public\\tinytdstest.bak' }
556
556
 
557
- after { File.delete(backup_file) if File.exists?(backup_file) }
557
+ after { File.delete(backup_file) if File.exist?(backup_file) }
558
558
 
559
559
  it 'must not cancel the query until complete' do
560
560
  @client.execute("BACKUP DATABASE tinytdstest TO DISK = '#{backup_file}'").do
data/test/test_helper.rb CHANGED
@@ -27,7 +27,7 @@ module TinyTds
27
27
  end
28
28
 
29
29
  after do
30
- @client.close if @client.is_a?(TinyTds::Client)
30
+ @client.close if defined?(@client) && @client.is_a?(TinyTds::Client)
31
31
  end
32
32
 
33
33
  protected
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_tds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3.rc2
4
+ version: 0.7.0
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - Ken Collins
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-07-31 00:00:00.000000000 Z
13
+ date: 2015-08-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mini_portile
@@ -134,6 +134,8 @@ files:
134
134
  - ports/x86_64-w64-mingw32/bin/libiconv-2.dll
135
135
  - ports/x86_64-w64-mingw32/bin/libsybdb-5.dll
136
136
  - ports/x86_64-w64-mingw32/bin/ssleay32-1.0.2d-x86_64-w64-mingw32.dll
137
+ - test/appveyor/dbsetup.ps1
138
+ - test/appveyor/dbsetup.sql
137
139
  - test/benchmark/query.rb
138
140
  - test/benchmark/query_odbc.rb
139
141
  - test/benchmark/query_tinytds.rb
@@ -165,9 +167,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
165
167
  version: '0'
166
168
  required_rubygems_version: !ruby/object:Gem::Requirement
167
169
  requirements:
168
- - - ">"
170
+ - - ">="
169
171
  - !ruby/object:Gem::Version
170
- version: 1.3.1
172
+ version: '0'
171
173
  requirements: []
172
174
  rubyforge_project:
173
175
  rubygems_version: 2.4.8