tiny_tds 2.1.5 → 3.2.0
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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +590 -0
- data/.gitignore +2 -0
- data/CHANGELOG.md +32 -1
- data/Gemfile +1 -8
- data/ISSUE_TEMPLATE.md +1 -1
- data/README.md +75 -88
- data/Rakefile +44 -30
- data/VERSION +1 -1
- data/docker-compose.yml +20 -8
- data/ext/tiny_tds/client.c +10 -15
- data/ext/tiny_tds/extconf.rb +183 -66
- data/ext/tiny_tds/extconsts.rb +4 -11
- data/ext/tiny_tds/result.c +28 -35
- data/ext/tiny_tds/tiny_tds_ext.c +4 -1
- data/lib/tiny_tds/bin.rb +12 -26
- data/lib/tiny_tds/client.rb +38 -42
- data/lib/tiny_tds/error.rb +0 -2
- data/lib/tiny_tds/gem.rb +5 -14
- data/lib/tiny_tds/result.rb +0 -2
- data/lib/tiny_tds/version.rb +1 -1
- data/lib/tiny_tds.rb +28 -47
- data/setup_cimgruby_dev.sh +25 -0
- data/start_dev.sh +21 -0
- data/tasks/native_gem.rake +12 -10
- data/tasks/package.rake +1 -3
- data/tasks/ports.rake +14 -75
- data/tasks/test.rake +3 -5
- data/test/bin/install-freetds.sh +2 -4
- data/test/bin/install-mssql.ps1 +42 -0
- data/test/bin/install-mssqltools.sh +9 -0
- data/test/bin/restore-from-native-gem.ps1 +10 -0
- data/test/bin/setup_tinytds_db.sh +7 -0
- data/test/bin/setup_volume_permissions.sh +10 -0
- data/test/client_test.rb +111 -120
- data/test/gem_test.rb +32 -111
- data/test/result_test.rb +259 -365
- data/test/schema_test.rb +369 -395
- data/test/sql/db-create.sql +18 -0
- data/test/sql/db-login.sql +38 -0
- data/test/test_helper.rb +75 -102
- data/test/thread_test.rb +22 -31
- data/tiny_tds.gemspec +28 -27
- metadata +70 -57
- data/.travis.yml +0 -25
- data/appveyor.yml +0 -72
- data/tasks/ports/freetds.rb +0 -37
- data/tasks/ports/libiconv.rb +0 -43
- data/tasks/ports/openssl.rb +0 -62
- data/tasks/ports/recipe.rb +0 -52
- data/test/appveyor/dbsetup.ps1 +0 -27
- data/test/appveyor/dbsetup.sql +0 -9
- data/test/benchmark/query.rb +0 -77
- data/test/benchmark/query_odbc.rb +0 -106
- data/test/benchmark/query_tinytds.rb +0 -126
- data/test/bin/setup.sh +0 -19
- data/test/schema/sqlserver_2000.sql +0 -140
- data/test/schema/sqlserver_2005.sql +0 -140
- data/test/schema/sqlserver_2014.sql +0 -140
- data/test/schema/sqlserver_2016.sql +0 -140
- data/test/schema/sybase_ase.sql +0 -138
- /data/test/schema/{sqlserver_2008.sql → sqlserver_2017.sql} +0 -0
data/README.md
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
# TinyTDS - Simple and fast FreeTDS bindings for Ruby using DB-Library.
|
2
2
|
|
3
|
-
* [](https://travis-ci.org/rails-sqlserver/tiny_tds) - TravisCI
|
4
|
-
* [](https://ci.appveyor.com/project/rails-sqlserver/tiny-tds/branch/master) - Appveyor
|
5
3
|
* [](https://rubygems.org/gems/tiny_tds) - Gem Version
|
6
4
|
* [](https://gitter.im/rails-sqlserver/activerecord-sqlserver-adapter) - Community
|
7
5
|
|
8
|
-
|
9
6
|
## About TinyTDS
|
10
7
|
|
11
|
-
The TinyTDS gem is meant to serve the extremely common use-case of connecting, querying and iterating over results to Microsoft SQL Server
|
8
|
+
The TinyTDS gem is meant to serve the extremely common use-case of connecting, querying and iterating over results to Microsoft SQL Server from Ruby using the FreeTDS's DB-Library API.
|
12
9
|
|
13
|
-
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.
|
10
|
+
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.
|
14
11
|
|
15
12
|
The API is simple and consists of these classes:
|
16
13
|
|
@@ -21,69 +18,71 @@ The API is simple and consists of these classes:
|
|
21
18
|
|
22
19
|
## Install
|
23
20
|
|
24
|
-
|
25
|
-
|
26
|
-
```
|
27
|
-
$ gem install tiny_tds
|
28
|
-
```
|
21
|
+
tiny_tds is tested with Ruby v2.7 and upwards.
|
29
22
|
|
30
|
-
|
31
|
-
If you're using RubyInstaller the binary gem will require that devkit is installed and in your path to operate properly.
|
23
|
+
### Windows and Linux (64-bit)
|
32
24
|
|
33
|
-
|
25
|
+
We precompile tiny_tds with FreeTDS and supporting libraries, which are dynamically linked at runtime. Therefore, you can run:
|
34
26
|
|
35
27
|
```shell
|
36
|
-
|
37
|
-
$ apt-get install build-essential
|
38
|
-
$ apt-get install libc6-dev
|
39
|
-
|
40
|
-
$ wget http://www.freetds.org/files/stable/freetds-1.1.24.tar.gz
|
41
|
-
$ tar -xzf freetds-1.1.24.tar.gz
|
42
|
-
$ cd freetds-1.1.24
|
43
|
-
$ ./configure --prefix=/usr/local --with-tdsver=7.3
|
44
|
-
$ make
|
45
|
-
$ make install
|
28
|
+
gem install tiny_tds
|
46
29
|
```
|
47
30
|
|
48
|
-
|
31
|
+
It should find the platform-specific gem.
|
49
32
|
|
50
|
-
|
51
|
-
--with-freetds-dir=DIR
|
52
|
-
Use the freetds library placed under DIR.
|
53
|
-
```
|
33
|
+
You can also avoid getting the platform-specific gem if you want to compile FreeTDS and supporting libraries yourself:
|
54
34
|
|
35
|
+
```shell
|
36
|
+
gem install tiny_tds --platform ruby
|
37
|
+
```
|
55
38
|
|
56
|
-
|
39
|
+
### Mac
|
57
40
|
|
58
|
-
|
41
|
+
Install FreeTDS via Homebrew:
|
59
42
|
|
60
|
-
|
61
|
-
|
62
|
-
|
43
|
+
```shell
|
44
|
+
brew install openssl@3 libiconv
|
45
|
+
brew install freetds
|
46
|
+
```
|
63
47
|
|
48
|
+
Then you can install tiny_tds:
|
64
49
|
|
65
|
-
|
50
|
+
```shell
|
51
|
+
gem install tiny_tds
|
52
|
+
```
|
66
53
|
|
67
|
-
|
54
|
+
### Everybody else
|
68
55
|
|
69
|
-
|
56
|
+
`tiny_tds` will find FreeTDS and other libraries based on your compiler paths. Below you can see an example on how to install FreeTDS on a Debian system.
|
70
57
|
|
71
|
-
|
58
|
+
```shell
|
59
|
+
$ apt-get install wget
|
60
|
+
$ apt-get install build-essential
|
61
|
+
$ apt-get install libc6-dev
|
72
62
|
|
73
|
-
|
63
|
+
$ wget http://www.freetds.org/files/stable/freetds-1.4.23.tar.gz
|
64
|
+
$ tar -xzf freetds-1.4.23.tar.gz
|
65
|
+
$ cd freetds-1.4.23
|
66
|
+
$ ./configure --prefix=/usr/local --with-tdsver=7.4 --disable-odbc
|
67
|
+
$ make
|
68
|
+
$ make install
|
69
|
+
```
|
74
70
|
|
75
|
-
|
71
|
+
You can also tell `tiny_tds` where to find your FreeTDS installation.
|
76
72
|
|
77
|
-
|
73
|
+
```shell
|
74
|
+
gem install tiny_tds -- --with-freetds-dir=/opt/freetds
|
75
|
+
```
|
78
76
|
|
79
|
-
|
77
|
+
## Getting Started
|
80
78
|
|
79
|
+
Optionally, Microsoft has done a great job writing [an article](https://learn.microsoft.com/en-us/sql/connect/ruby/ruby-driver-for-sql-server?view=sql-server-ver16) on how to get started with SQL Server and Ruby using TinyTDS, however, the articles are using outdated versions.
|
81
80
|
|
82
81
|
## Data Types
|
83
82
|
|
84
83
|
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. Only [datetimeoffset] types are excluded. All strings are associated the to the connection's encoding and all binary data types are associated to Ruby's `ASCII-8BIT/BINARY` encoding.
|
85
84
|
|
86
|
-
Below is a list of the data types we support when using the 7.
|
85
|
+
Below is a list of the data types we support when using the 7.4 TDS protocol version. Using a lower protocol version will result in these types being returned as strings.
|
87
86
|
|
88
87
|
* [date]
|
89
88
|
* [datetime2]
|
@@ -110,7 +109,7 @@ Creating a new client takes a hash of options. For valid iconv encoding options,
|
|
110
109
|
* :appname - Short string seen in SQL Servers process/activity window.
|
111
110
|
* :tds_version - TDS version. Defaults to "7.3".
|
112
111
|
* :login_timeout - Seconds to wait for login. Default to 60 seconds.
|
113
|
-
* :timeout - Seconds to wait for a response to a SQL command. Default 5 seconds.
|
112
|
+
* :timeout - Seconds to wait for a response to a SQL command. Default 5 seconds. Timeouts caused by network failure will raise a timeout error 1 second after the configured timeout limit is hit (see [#481](https://github.com/rails-sqlserver/tiny_tds/pull/481) for details).
|
114
113
|
* :encoding - Any valid iconv value like CP1251 or ISO-8859-1. Default UTF-8.
|
115
114
|
* :azure - Pass true to signal that you are connecting to azure.
|
116
115
|
* :contained - Pass true to signal that you are connecting with a contained database user.
|
@@ -392,28 +391,7 @@ Please read our [thread_test.rb](https://github.com/rails-sqlserver/tiny_tds/blo
|
|
392
391
|
|
393
392
|
## Emoji Support 😍
|
394
393
|
|
395
|
-
This is possible
|
396
|
-
|
397
|
-
```ini
|
398
|
-
[global]
|
399
|
-
use utf-16 = true
|
400
|
-
```
|
401
|
-
|
402
|
-
The default is true and since FreeTDS v1.0 would do this as well.
|
403
|
-
|
404
|
-
|
405
|
-
## Compiling Gems for Windows
|
406
|
-
|
407
|
-
For the convenience of Windows users, TinyTDS ships pre-compiled gems for supported versions of Ruby on Windows. In order to generate these gems, [rake-compiler-dock](https://github.com/rake-compiler/rake-compiler-dock) is used. This project provides several [Docker images](https://registry.hub.docker.com/u/larskanis/) with rvm, cross-compilers and a number of different target versions of Ruby.
|
408
|
-
|
409
|
-
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:
|
410
|
-
|
411
|
-
```
|
412
|
-
$ rake gem:windows
|
413
|
-
```
|
414
|
-
|
415
|
-
The compiled gems will exist in `./pkg` directory.
|
416
|
-
|
394
|
+
This is possible. Since FreeTDS v1.0, utf-16 is enabled by default and supported by tiny_tds. You can toggle it by using `use_utf16` when establishing the connection.
|
417
395
|
|
418
396
|
## Development & Testing
|
419
397
|
|
@@ -429,27 +407,21 @@ After that, the quickest way to get setup for development is to use [Docker](htt
|
|
429
407
|
$ docker-compose up -d
|
430
408
|
```
|
431
409
|
|
432
|
-
This will download
|
410
|
+
This will download the official SQL Server for Linux Docker image from [Microsoft](https://hub.docker.com/r/microsoft/mssql-server-linux/). This will also download a [toxiproxy](https://github.com/shopify/toxiproxy) Docker image which we can use to simulate network failures for tests. Basically, it does the following:
|
433
411
|
|
434
412
|
```shell
|
435
413
|
$ docker network create main-network
|
436
|
-
$ docker pull
|
437
|
-
$ docker run -p 1433:1433 -d --name sqlserver --network main-network
|
414
|
+
$ docker pull mcr.microsoft.com/mssql/server:2017-latest
|
415
|
+
$ docker run -p 1433:1433 -d --name sqlserver --network main-network mcr.microsoft.com/mssql/server:2017-latest
|
438
416
|
$ docker pull shopify/toxiproxy
|
439
417
|
$ docker run -p 8474:8474 -p 1234:1234 -d --name toxiproxy --network main-network shopify/toxiproxy
|
440
418
|
```
|
441
419
|
|
442
|
-
|
443
|
-
|
444
|
-
```sql
|
445
|
-
CREATE DATABASE [tinytdstest];
|
446
|
-
```
|
420
|
+
Make sure to run these SQL scripts as SA to get the test database and user installed. If needed, install [sqlcmd as described by Microsoft for your platform](https://learn.microsoft.com/en-us/sql/tools/sqlcmd/sqlcmd-utility?view=sql-server-ver16&tabs=go%2Clinux&pivots=cs1-bash).
|
447
421
|
|
448
|
-
```
|
449
|
-
|
450
|
-
|
451
|
-
CREATE USER [tinytds] FOR LOGIN [tinytds];
|
452
|
-
EXEC sp_addrolemember N'db_owner', N'tinytds';
|
422
|
+
```shell
|
423
|
+
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P super01S3cUr3 -i ./test/sql/db-create.sql
|
424
|
+
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P super01S3cUr3 -i ./test/sql/db-login.sql
|
453
425
|
```
|
454
426
|
|
455
427
|
From here you can build and run tests against an installed version of FreeTDS.
|
@@ -463,21 +435,36 @@ Examples us using enviornment variables to customize the test task.
|
|
463
435
|
|
464
436
|
```
|
465
437
|
$ rake TINYTDS_UNIT_DATASERVER=mydbserver
|
466
|
-
$ rake TINYTDS_UNIT_DATASERVER=mydbserver TINYTDS_SCHEMA=
|
438
|
+
$ rake TINYTDS_UNIT_DATASERVER=mydbserver TINYTDS_SCHEMA=sqlserver_2017
|
467
439
|
$ rake TINYTDS_UNIT_HOST=mydb.host.net TINYTDS_SCHEMA=sqlserver_azure
|
468
|
-
$ rake TINYTDS_UNIT_HOST=mydb.host.net TINYTDS_UNIT_PORT=5000 TINYTDS_SCHEMA=sybase_ase
|
469
440
|
```
|
470
441
|
|
471
|
-
|
442
|
+
### Code formatting
|
443
|
+
|
444
|
+
We are using `standardrb` to format our code. Just run `bundle exec standardrb --fix` to format all Ruby files.
|
445
|
+
|
446
|
+
### Compiling Gems for Windows and Linux
|
447
|
+
|
448
|
+
> [!WARNING]
|
449
|
+
> Compiling the Gems on native Windows currently does not work.
|
450
|
+
|
451
|
+
For the convenience, TinyTDS ships pre-compiled gems for supported versions of Ruby on Windows and Linux. In order to generate these gems, [rake-compiler-dock](https://github.com/rake-compiler/rake-compiler-dock) is used.
|
452
|
+
|
453
|
+
Run the following rake task to compile the gems. This will check the availability of [Docker](https://www.docker.com/) 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:
|
454
|
+
|
455
|
+
```shell
|
456
|
+
bundle exec rake gem:native
|
457
|
+
```
|
458
|
+
|
459
|
+
The compiled gems will exist in `./pkg` directory.
|
472
460
|
|
473
|
-
If you
|
474
|
-
into another, lighter, container without build tools you will need to make sure you tell the OS how to find dependencies for TinyTDS.
|
461
|
+
If you only need a specific gem for one platform and architecture, run this command:
|
475
462
|
|
476
|
-
|
477
|
-
|
463
|
+
```shell
|
464
|
+
bundle exec rake gem:native:x64-mingw-ucrt
|
465
|
+
```
|
478
466
|
|
479
|
-
|
480
|
-
sure you also copied in the library dependencies from your build container with a command like `COPY --from=builder /usr/local/lib /usr/local/lib`.
|
467
|
+
All the supported architectures and platforms are listed in the `Rakefile` in the `CrossLibraries` constant.
|
481
468
|
|
482
469
|
## Help & Support
|
483
470
|
|
@@ -503,4 +490,4 @@ My name is Ken Collins and I currently maintain the SQL Server adapter for Activ
|
|
503
490
|
|
504
491
|
## License
|
505
492
|
|
506
|
-
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
|
493
|
+
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 and Linux binaries contain pre-compiled versions of FreeTDS <http://www.freetds.org/> and `libconv` which is licensed under the GNU LGPL license at <http://www.gnu.org/licenses/lgpl-2.0.html>. They also contain OpenSSL, which is licensed under the OpenSSL license at <https://openssl-library.org/source/license/index.html>.
|
data/Rakefile
CHANGED
@@ -1,18 +1,24 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
require "rbconfig"
|
2
|
+
require "rake"
|
3
|
+
require "rake/clean"
|
4
|
+
require "rake/extensiontask"
|
5
|
+
|
6
|
+
SPEC = Gem::Specification.load(File.expand_path("../tiny_tds.gemspec", __FILE__))
|
7
|
+
|
8
|
+
CrossLibrary = Struct.new :platform, :openssl_config
|
9
|
+
CrossLibraries = [
|
10
|
+
["x64-mingw-ucrt", "mingw64"],
|
11
|
+
["x64-mingw32", "mingw64"],
|
12
|
+
["x86_64-linux-gnu", "linux-x86_64"],
|
13
|
+
["x86_64-linux-musl", "linux-x86_64"],
|
14
|
+
["aarch64-linux-gnu", "linux-aarch64"],
|
15
|
+
["aarch64-linux-musl", "linux-aarch64"]
|
16
|
+
].map do |platform, openssl_config|
|
17
|
+
CrossLibrary.new platform, openssl_config
|
18
|
+
end
|
13
19
|
|
14
20
|
# Add our project specific files to clean for a rebuild
|
15
|
-
CLEAN.include FileList["{ext,lib}/**/*.{so,#{RbConfig::CONFIG[
|
21
|
+
CLEAN.include FileList["{ext,lib}/**/*.{so,#{RbConfig::CONFIG["DLEXT"]},o}"],
|
16
22
|
FileList["exe/*"]
|
17
23
|
|
18
24
|
# Clobber all our temp files and ports files including .install files
|
@@ -20,34 +26,42 @@ CLEAN.include FileList["{ext,lib}/**/*.{so,#{RbConfig::CONFIG['DLEXT']},o}"],
|
|
20
26
|
CLOBBER.include FileList["tmp/**/*"],
|
21
27
|
FileList["ports/**/*"].exclude(%r{^ports/archives})
|
22
28
|
|
23
|
-
Dir[
|
29
|
+
Dir["tasks/*.rake"].sort.each { |f| load f }
|
24
30
|
|
25
|
-
Rake::ExtensionTask.new(
|
26
|
-
ext.lib_dir =
|
31
|
+
Rake::ExtensionTask.new("tiny_tds", SPEC) do |ext|
|
32
|
+
ext.lib_dir = "lib/tiny_tds"
|
27
33
|
ext.cross_compile = true
|
28
|
-
ext.cross_platform =
|
34
|
+
ext.cross_platform = CrossLibraries.map(&:platform)
|
29
35
|
|
30
36
|
# Add dependent DLLs to the cross gems
|
31
37
|
ext.cross_compiling do |spec|
|
32
38
|
# The fat binary gem doesn't depend on the freetds package, since it bundles the library.
|
33
|
-
spec.metadata.delete(
|
34
|
-
|
35
|
-
platform_host_map = GEM_PLATFORM_HOSTS
|
36
|
-
gemplat = spec.platform.to_s
|
37
|
-
host = platform_host_map[gemplat]
|
39
|
+
spec.metadata.delete("msys2_mingw_dependencies")
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
if /mingw/.match?(spec.platform.to_s)
|
42
|
+
spec.files += [
|
43
|
+
"ports/#{spec.platform}/bin/libsybdb-5.dll",
|
44
|
+
"ports/#{spec.platform}/bin/defncopy.exe",
|
45
|
+
"ports/#{spec.platform}/bin/tsql.exe"
|
46
|
+
]
|
47
|
+
elsif /linux/.match?(spec.platform.to_s)
|
48
|
+
spec.files += [
|
49
|
+
"ports/#{spec.platform}/lib/libsybdb.so.5",
|
50
|
+
"ports/#{spec.platform}/bin/defncopy",
|
51
|
+
"ports/#{spec.platform}/bin/tsql"
|
52
|
+
]
|
45
53
|
end
|
54
|
+
end
|
46
55
|
|
47
|
-
|
56
|
+
ext.cross_config_options += CrossLibraries.map do |xlib|
|
57
|
+
{
|
58
|
+
xlib.platform => [
|
59
|
+
"--with-cross-build=#{xlib.platform}",
|
60
|
+
"--with-openssl-platform=#{xlib.openssl_config}"
|
61
|
+
]
|
62
|
+
}
|
48
63
|
end
|
49
64
|
end
|
50
65
|
|
51
66
|
task build: [:clean, :compile]
|
52
67
|
task default: [:build, :test]
|
53
|
-
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
3.2.0
|
data/docker-compose.yml
CHANGED
@@ -5,18 +5,30 @@ networks:
|
|
5
5
|
|
6
6
|
services:
|
7
7
|
mssql:
|
8
|
-
image:
|
8
|
+
image: mcr.microsoft.com/mssql/server:${MSSQL_VERSION:-2017}-latest
|
9
9
|
container_name: sqlserver
|
10
|
+
environment:
|
11
|
+
ACCEPT_EULA: Y
|
12
|
+
MSSQL_SA_PASSWORD: super01S3cUr3
|
10
13
|
ports:
|
11
14
|
- "1433:1433"
|
12
|
-
|
13
|
-
- main-network
|
15
|
+
network_mode: "host"
|
14
16
|
|
15
17
|
toxiproxy:
|
16
18
|
image: shopify/toxiproxy
|
17
19
|
container_name: toxiproxy
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
command: '/toxiproxy -host=127.0.0.1'
|
21
|
+
network_mode: "host"
|
22
|
+
|
23
|
+
cimgruby:
|
24
|
+
image: "cimg/ruby:${RUBY_VERSION:-2.7}"
|
25
|
+
container_name: cimg_ruby
|
26
|
+
environment:
|
27
|
+
TESTOPTS: '-v'
|
28
|
+
TINYTDS_UNIT_HOST: '127.0.0.1'
|
29
|
+
SA_PASSWORD: super01S3cUr3
|
30
|
+
TOXIPROXY_HOST: '127.0.0.1'
|
31
|
+
command: tail -F anything
|
32
|
+
volumes:
|
33
|
+
- .:/home/circleci/project
|
34
|
+
network_mode: "host"
|
data/ext/tiny_tds/client.c
CHANGED
@@ -232,6 +232,7 @@ static void rb_tinytds_client_free(void *ptr) {
|
|
232
232
|
dbloginfree(cwrap->login);
|
233
233
|
if (cwrap->client && !cwrap->closed) {
|
234
234
|
dbclose(cwrap->client);
|
235
|
+
cwrap->client = NULL;
|
235
236
|
cwrap->closed = 1;
|
236
237
|
cwrap->userdata->closed = 1;
|
237
238
|
}
|
@@ -263,6 +264,7 @@ static VALUE rb_tinytds_close(VALUE self) {
|
|
263
264
|
GET_CLIENT_WRAPPER(self);
|
264
265
|
if (cwrap->client && !cwrap->closed) {
|
265
266
|
dbclose(cwrap->client);
|
267
|
+
cwrap->client = NULL;
|
266
268
|
cwrap->closed = 1;
|
267
269
|
cwrap->userdata->closed = 1;
|
268
270
|
}
|
@@ -297,8 +299,7 @@ static VALUE rb_tinytds_execute(VALUE self, VALUE sql) {
|
|
297
299
|
REQUIRE_OPEN_CLIENT(cwrap);
|
298
300
|
dbcmd(cwrap->client, StringValueCStr(sql));
|
299
301
|
if (dbsqlsend(cwrap->client) == FAIL) {
|
300
|
-
|
301
|
-
return Qfalse;
|
302
|
+
rb_raise(cTinyTdsError, "failed dbsqlsend() function");
|
302
303
|
}
|
303
304
|
cwrap->userdata->dbsql_sent = 1;
|
304
305
|
result = rb_tinytds_new_result_obj(cwrap);
|
@@ -402,17 +403,15 @@ static VALUE rb_tinytds_connect(VALUE self, VALUE opts) {
|
|
402
403
|
#endif
|
403
404
|
}
|
404
405
|
}
|
405
|
-
|
406
|
-
|
407
|
-
if (use_utf16 == Qfalse) { DBSETLUTF16(cwrap->login, 0); }
|
408
|
-
#else
|
409
|
-
if (use_utf16 == Qtrue || use_utf16 == Qfalse) {
|
410
|
-
rb_warning("TinyTds: Please consider upgrading to FreeTDS 0.99 or higher for better unicode support.\n");
|
411
|
-
}
|
412
|
-
#endif
|
406
|
+
if (use_utf16 == Qtrue) { DBSETLUTF16(cwrap->login, 1); }
|
407
|
+
if (use_utf16 == Qfalse) { DBSETLUTF16(cwrap->login, 0); }
|
413
408
|
|
414
409
|
cwrap->client = dbopen(cwrap->login, StringValueCStr(dataserver));
|
415
410
|
if (cwrap->client) {
|
411
|
+
if (dbtds(cwrap->client) < 11) {
|
412
|
+
rb_raise(cTinyTdsError, "connecting with a TDS version older than 7.3!");
|
413
|
+
}
|
414
|
+
|
416
415
|
VALUE transposed_encoding, timeout_string;
|
417
416
|
|
418
417
|
cwrap->closed = 0;
|
@@ -433,11 +432,7 @@ static VALUE rb_tinytds_connect(VALUE self, VALUE opts) {
|
|
433
432
|
}
|
434
433
|
transposed_encoding = rb_funcall(cTinyTdsClient, intern_transpose_iconv_encoding, 1, charset);
|
435
434
|
cwrap->encoding = rb_enc_find(StringValueCStr(transposed_encoding));
|
436
|
-
|
437
|
-
cwrap->identity_insert_sql = "SELECT CAST(@@IDENTITY AS bigint) AS Ident";
|
438
|
-
} else {
|
439
|
-
cwrap->identity_insert_sql = "SELECT CAST(SCOPE_IDENTITY() AS bigint) AS Ident";
|
440
|
-
}
|
435
|
+
cwrap->identity_insert_sql = "SELECT CAST(SCOPE_IDENTITY() AS bigint) AS Ident";
|
441
436
|
}
|
442
437
|
return self;
|
443
438
|
}
|