tiny_tds 2.1.2 → 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 +5 -5
- data/.github/workflows/ci.yml +590 -0
- data/.gitignore +2 -0
- data/CHANGELOG.md +51 -1
- data/Gemfile +1 -8
- data/ISSUE_TEMPLATE.md +1 -1
- data/README.md +89 -89
- data/Rakefile +44 -30
- data/VERSION +1 -1
- data/docker-compose.yml +34 -0
- data/ext/tiny_tds/client.c +100 -59
- data/ext/tiny_tds/client.h +5 -3
- data/ext/tiny_tds/extconf.rb +173 -52
- data/ext/tiny_tds/extconsts.rb +4 -11
- data/ext/tiny_tds/result.c +52 -45
- 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 -77
- 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 +152 -116
- data/test/gem_test.rb +39 -118
- data/test/result_test.rb +285 -350
- 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 +112 -85
- data/test/thread_test.rb +22 -31
- data/tiny_tds.gemspec +28 -26
- metadata +85 -59
- data/.travis.yml +0 -24
- data/BACKERS.md +0 -32
- data/appveyor.yml +0 -51
- data/tasks/ports/freetds.rb +0 -37
- data/tasks/ports/libiconv.rb +0 -43
- data/tasks/ports/openssl.rb +0 -78
- 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,21 +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
|
-
* [](https://dependencyci.com/github/rails-sqlserver/tiny_tds) - Dependency Status
|
7
4
|
* [](https://gitter.im/rails-sqlserver/activerecord-sqlserver-adapter) - Community
|
8
5
|
|
9
|
-
## Supporting TinyTDS/Adapter
|
10
|
-
|
11
|
-
Both TinyTDS and the Rails SQL Server Adapter are MIT-licensed open source projects. Its ongoing development is made possible thanks to the support by these awesome [backers](https://github.com/rails-sqlserver/tiny_tds/blob/master/BACKERS.md). If you'd like to join them, check out our [Patreon Campaign](https://www.patreon.com/metaskills).
|
12
|
-
|
13
|
-
|
14
6
|
## About TinyTDS
|
15
7
|
|
16
|
-
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.
|
17
9
|
|
18
|
-
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.
|
19
11
|
|
20
12
|
The API is simple and consists of these classes:
|
21
13
|
|
@@ -26,69 +18,71 @@ The API is simple and consists of these classes:
|
|
26
18
|
|
27
19
|
## Install
|
28
20
|
|
29
|
-
|
21
|
+
tiny_tds is tested with Ruby v2.7 and upwards.
|
30
22
|
|
31
|
-
|
32
|
-
$ gem install tiny_tds
|
33
|
-
```
|
23
|
+
### Windows and Linux (64-bit)
|
34
24
|
|
35
|
-
|
36
|
-
If you're using RubyInstaller the binary gem will require that devkit is installed and in your path to operate properly.
|
37
|
-
|
38
|
-
On all other platforms, we will find these dependencies. It is recommended that you install the latest FreeTDS via your method of choice. For example, here is how to install FreeTDS on Ubuntu. You might also need the `build-essential` and possibly the `libc6-dev` packages.
|
25
|
+
We precompile tiny_tds with FreeTDS and supporting libraries, which are dynamically linked at runtime. Therefore, you can run:
|
39
26
|
|
40
27
|
```shell
|
41
|
-
|
42
|
-
$ apt-get install build-essential
|
43
|
-
$ apt-get install libc6-dev
|
44
|
-
|
45
|
-
$ wget http://www.freetds.org/files/stable/freetds-1.00.21.tar.gz
|
46
|
-
$ tar -xzf freetds-1.00.21.tar.gz
|
47
|
-
$ cd freetds-1.00.21
|
48
|
-
$ ./configure --prefix=/usr/local --with-tdsver=7.3
|
49
|
-
$ make
|
50
|
-
$ make install
|
28
|
+
gem install tiny_tds
|
51
29
|
```
|
52
30
|
|
53
|
-
|
31
|
+
It should find the platform-specific gem.
|
54
32
|
|
55
|
-
|
56
|
-
--with-freetds-dir=DIR
|
57
|
-
Use the freetds library placed under DIR.
|
58
|
-
```
|
33
|
+
You can also avoid getting the platform-specific gem if you want to compile FreeTDS and supporting libraries yourself:
|
59
34
|
|
35
|
+
```shell
|
36
|
+
gem install tiny_tds --platform ruby
|
37
|
+
```
|
60
38
|
|
61
|
-
|
39
|
+
### Mac
|
62
40
|
|
63
|
-
|
41
|
+
Install FreeTDS via Homebrew:
|
64
42
|
|
65
|
-
|
66
|
-
|
67
|
-
|
43
|
+
```shell
|
44
|
+
brew install openssl@3 libiconv
|
45
|
+
brew install freetds
|
46
|
+
```
|
68
47
|
|
48
|
+
Then you can install tiny_tds:
|
69
49
|
|
70
|
-
|
50
|
+
```shell
|
51
|
+
gem install tiny_tds
|
52
|
+
```
|
71
53
|
|
72
|
-
|
54
|
+
### Everybody else
|
73
55
|
|
74
|
-
|
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.
|
75
57
|
|
76
|
-
|
58
|
+
```shell
|
59
|
+
$ apt-get install wget
|
60
|
+
$ apt-get install build-essential
|
61
|
+
$ apt-get install libc6-dev
|
77
62
|
|
78
|
-
|
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
|
+
```
|
79
70
|
|
80
|
-
|
71
|
+
You can also tell `tiny_tds` where to find your FreeTDS installation.
|
81
72
|
|
82
|
-
|
73
|
+
```shell
|
74
|
+
gem install tiny_tds -- --with-freetds-dir=/opt/freetds
|
75
|
+
```
|
83
76
|
|
84
|
-
|
77
|
+
## Getting Started
|
85
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.
|
86
80
|
|
87
81
|
## Data Types
|
88
82
|
|
89
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.
|
90
84
|
|
91
|
-
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.
|
92
86
|
|
93
87
|
* [date]
|
94
88
|
* [datetime2]
|
@@ -115,7 +109,7 @@ Creating a new client takes a hash of options. For valid iconv encoding options,
|
|
115
109
|
* :appname - Short string seen in SQL Servers process/activity window.
|
116
110
|
* :tds_version - TDS version. Defaults to "7.3".
|
117
111
|
* :login_timeout - Seconds to wait for login. Default to 60 seconds.
|
118
|
-
* :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).
|
119
113
|
* :encoding - Any valid iconv value like CP1251 or ISO-8859-1. Default UTF-8.
|
120
114
|
* :azure - Pass true to signal that you are connecting to azure.
|
121
115
|
* :contained - Pass true to signal that you are connecting with a contained database user.
|
@@ -327,9 +321,13 @@ By default row caching is turned on because the SQL Server adapter for ActiveRec
|
|
327
321
|
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.
|
328
322
|
|
329
323
|
|
324
|
+
## Timeout Error Handling
|
325
|
+
|
326
|
+
TinyTDS will raise a `TinyTDS::Error` when a timeout is reached based on the options supplied to the client. Depending on the reason for the timeout, the connection could be dead or alive. When db processing is the cause for the timeout, the connection should still be usable after the error is raised. When network failure is the cause of the timeout, the connection will be dead. If you attempt to execute another command batch on a dead connection you will see a `DBPROCESS is dead or not enabled` error. Therefore, it is recommended to check for a `dead?` connection before trying to execute another command batch.
|
327
|
+
|
330
328
|
## Binstubs
|
331
329
|
|
332
|
-
The TinyTDS gem uses binstub wrappers which mirror compiled [FreeTDS Utilities](
|
330
|
+
The TinyTDS gem uses binstub wrappers which mirror compiled [FreeTDS Utilities](https://www.freetds.org/userguide/usefreetds.html) binaries. These native executables are usually installed at the system level when installing FreeTDS. However, when using MiniPortile to install TinyTDS as we do with Windows binaries, these binstubs will find and prefer local gem `exe` directory executables. These are the following binstubs we wrap.
|
333
331
|
|
334
332
|
* tsql - Used to test connections and debug compile time settings.
|
335
333
|
* defncopy - Used to dump schema structures.
|
@@ -393,28 +391,7 @@ Please read our [thread_test.rb](https://github.com/rails-sqlserver/tiny_tds/blo
|
|
393
391
|
|
394
392
|
## Emoji Support 😍
|
395
393
|
|
396
|
-
This is possible
|
397
|
-
|
398
|
-
```ini
|
399
|
-
[global]
|
400
|
-
use utf-16 = true
|
401
|
-
```
|
402
|
-
|
403
|
-
The default is true and since FreeTDS v1.0 would do this as well.
|
404
|
-
|
405
|
-
|
406
|
-
## Compiling Gems for Windows
|
407
|
-
|
408
|
-
For the convenience of Windows users, TinyTDS ships pre-compiled gems for Ruby 2.0, 2.1, 2.2, and 2.3 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.
|
409
|
-
|
410
|
-
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:
|
411
|
-
|
412
|
-
```
|
413
|
-
$ rake gem:windows
|
414
|
-
```
|
415
|
-
|
416
|
-
The compiled gems will exist in `./pkg` directory.
|
417
|
-
|
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.
|
418
395
|
|
419
396
|
## Development & Testing
|
420
397
|
|
@@ -424,30 +401,27 @@ First, clone the repo using the command line or your Git GUI of choice.
|
|
424
401
|
$ git clone git@github.com:rails-sqlserver/tiny_tds.git
|
425
402
|
```
|
426
403
|
|
427
|
-
After that, the quickest way to get setup for development is to use [Docker](https://www.docker.com/). Assuming you have [downloaded docker](https://www.docker.com/products/docker) for your platform
|
404
|
+
After that, the quickest way to get setup for development is to use [Docker](https://www.docker.com/). Assuming you have [downloaded docker](https://www.docker.com/products/docker) for your platform, you can use [docker-compose](https://docs.docker.com/compose/install/) to run the necessary containers for testing.
|
428
405
|
|
429
406
|
```shell
|
430
|
-
$
|
407
|
+
$ docker-compose up -d
|
431
408
|
```
|
432
409
|
|
433
|
-
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:
|
434
411
|
|
435
412
|
```shell
|
436
|
-
$ docker
|
437
|
-
$ docker
|
413
|
+
$ docker network create 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
|
416
|
+
$ docker pull shopify/toxiproxy
|
417
|
+
$ docker run -p 8474:8474 -p 1234:1234 -d --name toxiproxy --network main-network shopify/toxiproxy
|
438
418
|
```
|
439
419
|
|
440
|
-
|
441
|
-
|
442
|
-
```sql
|
443
|
-
CREATE DATABASE [tinytdstest];
|
444
|
-
```
|
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).
|
445
421
|
|
446
|
-
```
|
447
|
-
|
448
|
-
|
449
|
-
CREATE USER [tinytds] FOR LOGIN [tinytds];
|
450
|
-
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
|
451
425
|
```
|
452
426
|
|
453
427
|
From here you can build and run tests against an installed version of FreeTDS.
|
@@ -461,11 +435,37 @@ Examples us using enviornment variables to customize the test task.
|
|
461
435
|
|
462
436
|
```
|
463
437
|
$ rake TINYTDS_UNIT_DATASERVER=mydbserver
|
464
|
-
$ rake TINYTDS_UNIT_DATASERVER=mydbserver TINYTDS_SCHEMA=
|
438
|
+
$ rake TINYTDS_UNIT_DATASERVER=mydbserver TINYTDS_SCHEMA=sqlserver_2017
|
465
439
|
$ rake TINYTDS_UNIT_HOST=mydb.host.net TINYTDS_SCHEMA=sqlserver_azure
|
466
|
-
$ rake TINYTDS_UNIT_HOST=mydb.host.net TINYTDS_UNIT_PORT=5000 TINYTDS_SCHEMA=sybase_ase
|
467
440
|
```
|
468
441
|
|
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.
|
460
|
+
|
461
|
+
If you only need a specific gem for one platform and architecture, run this command:
|
462
|
+
|
463
|
+
```shell
|
464
|
+
bundle exec rake gem:native:x64-mingw-ucrt
|
465
|
+
```
|
466
|
+
|
467
|
+
All the supported architectures and platforms are listed in the `Rakefile` in the `CrossLibraries` constant.
|
468
|
+
|
469
469
|
## Help & Support
|
470
470
|
|
471
471
|
* Github Source: http://github.com/rails-sqlserver/tiny_tds
|
@@ -490,4 +490,4 @@ My name is Ken Collins and I currently maintain the SQL Server adapter for Activ
|
|
490
490
|
|
491
491
|
## License
|
492
492
|
|
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 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
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
version: '3'
|
2
|
+
|
3
|
+
networks:
|
4
|
+
main-network:
|
5
|
+
|
6
|
+
services:
|
7
|
+
mssql:
|
8
|
+
image: mcr.microsoft.com/mssql/server:${MSSQL_VERSION:-2017}-latest
|
9
|
+
container_name: sqlserver
|
10
|
+
environment:
|
11
|
+
ACCEPT_EULA: Y
|
12
|
+
MSSQL_SA_PASSWORD: super01S3cUr3
|
13
|
+
ports:
|
14
|
+
- "1433:1433"
|
15
|
+
network_mode: "host"
|
16
|
+
|
17
|
+
toxiproxy:
|
18
|
+
image: shopify/toxiproxy
|
19
|
+
container_name: toxiproxy
|
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"
|