tiny_tds 2.1.2 → 3.4.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/.devcontainer/Dockerfile +21 -0
- data/.devcontainer/boot.sh +6 -0
- data/.devcontainer/compose.yaml +40 -0
- data/.devcontainer/devcontainer.json +30 -0
- data/.github/workflows/ci.yml +586 -0
- data/.gitignore +2 -0
- data/CHANGELOG.md +71 -1
- data/Gemfile +1 -8
- data/ISSUE_TEMPLATE.md +1 -1
- data/README.md +81 -97
- data/Rakefile +48 -29
- data/VERSION +1 -1
- data/astyle.conf +8 -0
- data/ext/tiny_tds/client.c +252 -112
- 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 +223 -87
- data/ext/tiny_tds/result.h +2 -2
- data/ext/tiny_tds/tiny_tds_ext.c +6 -2
- data/lib/tiny_tds/bin.rb +14 -28
- data/lib/tiny_tds/client.rb +38 -42
- data/lib/tiny_tds/error.rb +0 -2
- data/lib/tiny_tds/gem.rb +7 -16
- data/lib/tiny_tds/result.rb +0 -2
- data/lib/tiny_tds/version.rb +1 -1
- data/lib/tiny_tds.rb +27 -47
- 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/restore-from-native-gem.ps1 +16 -0
- data/test/client_test.rb +152 -116
- data/test/gem_test.rb +40 -124
- 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 +21 -38
- data/tiny_tds.gemspec +31 -26
- metadata +114 -63
- 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/install-openssl.sh +0 -18
- 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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,72 @@
|
|
|
1
|
+
## (unreleased)
|
|
2
|
+
|
|
3
|
+
## 3.4.0
|
|
4
|
+
|
|
5
|
+
* Add Ruby 4.0 to the cross compile list
|
|
6
|
+
* No longer ship a precompiled Gem for Ruby 2.7
|
|
7
|
+
* This is due to an [upstream change](https://github.com/rake-compiler/rake-compiler-dock/releases/tag/v1.11.0). Users on Windows and Linux on Ruby v2.7 are advised to either upgrade or install FreeTDS manually.
|
|
8
|
+
* Use freetds v1.5.10 and OpenSSL v3.6.0 for Windows and Linux builds.
|
|
9
|
+
* Lower `bigdecimal` requirement to `>= 2.0.0` (was 3.0 only) to allow `bigdecimal` 4.0 on Ruby 4.0. Closes #601.
|
|
10
|
+
|
|
11
|
+
## 3.3.0
|
|
12
|
+
|
|
13
|
+
* Use freetds v1.5.4 and OpenSSL v3.5.2 for Windows and Linux builds.
|
|
14
|
+
* Use `TypedData` in C-Land.
|
|
15
|
+
|
|
16
|
+
## 3.2.1
|
|
17
|
+
|
|
18
|
+
* Ensure the native Gem loads on Windows. Fixes #581.
|
|
19
|
+
* Use OpenSSL v3.4.1 for Windows and Linux builds.
|
|
20
|
+
|
|
21
|
+
## 3.2.0
|
|
22
|
+
|
|
23
|
+
* Reduce number of files shipped with precompiled Windows gem
|
|
24
|
+
* Provide precompiled gem for Linux (GNU + MUSL / 64-bit x86 + ARM)
|
|
25
|
+
* Fix wrappers for `tsql` and `defncopy` utility.
|
|
26
|
+
* Use libiconv v1.18 and freetds v1.4.26 for Windows and Linux builds
|
|
27
|
+
|
|
28
|
+
## 3.1.0
|
|
29
|
+
|
|
30
|
+
* Add Ruby 3.4 to the cross compile list
|
|
31
|
+
|
|
32
|
+
## 3.0.0
|
|
33
|
+
|
|
34
|
+
* Drop support for Ruby < 2.7
|
|
35
|
+
* Drop support for SQL Server < 2017
|
|
36
|
+
* Drop support for FreeTDS < 1.0
|
|
37
|
+
* No longer provide a 32-bit Windows build
|
|
38
|
+
* Raise error if FreeTDS is unable to send command buffer to the server
|
|
39
|
+
* Use freetds v1.4.23, libiconv v1.17 and OpenSSL v3.4.0 for Windows builds
|
|
40
|
+
* Add `bigdecimal` to dependencies
|
|
41
|
+
|
|
42
|
+
## 2.1.7
|
|
43
|
+
|
|
44
|
+
* Add Ruby 3.3 to the cross compile list
|
|
45
|
+
|
|
46
|
+
## 2.1.6
|
|
47
|
+
|
|
48
|
+
* Add Ruby 3.0, 3.1, and 3.2 to the cross compile list
|
|
49
|
+
* Fix segfault when asking if client was dead after closing it. Fixes #519.
|
|
50
|
+
* Mark `alloc` function as undefined on `TinyTds::Result`. Fixes #515.
|
|
51
|
+
* Fix Gem installation on Windows by adding default freetds msys path. Fixes #522
|
|
52
|
+
* Search for `freetds` in `/opt/homebrew` when installing on Apple Silicon. Fixes #484, #492 and #508.
|
|
53
|
+
|
|
54
|
+
## 2.1.5
|
|
55
|
+
|
|
56
|
+
* Fix compilation errors for Amazon Linux 1. Fixes #495.
|
|
57
|
+
* Fix segfault for login timeouts
|
|
58
|
+
|
|
59
|
+
## 2.1.4
|
|
60
|
+
|
|
61
|
+
* Improve handling of network related timeouts
|
|
62
|
+
* Fix error reporting when preceded by info message
|
|
63
|
+
|
|
64
|
+
## 2.1.3
|
|
65
|
+
|
|
66
|
+
* Removed old/unused appveyor config
|
|
67
|
+
* Remove old Rubies from CI & cross compile list
|
|
68
|
+
* Add Ruby 2.6 and 2.7 to the cross compile list
|
|
69
|
+
|
|
1
70
|
## 2.1.2
|
|
2
71
|
|
|
3
72
|
* Use Kernel.BigDecimal vs BigDecimal.new. Fixes #409.
|
|
@@ -207,6 +276,8 @@ Use both dbsetversion() vs. dbsetlversion. Partially reverts #62.
|
|
|
207
276
|
state of the client and the need to use Result#cancel to stop processing active results. It is also
|
|
208
277
|
safe to call Result#cancel over and over again.
|
|
209
278
|
* Look for the syb headers only.
|
|
279
|
+
* Fix minitest global matchers warnings.
|
|
280
|
+
* Fix test warnings.
|
|
210
281
|
|
|
211
282
|
|
|
212
283
|
## 0.3.2
|
|
@@ -252,4 +323,3 @@ Use both dbsetversion() vs. dbsetlversion. Partially reverts #62.
|
|
|
252
323
|
|
|
253
324
|
|
|
254
325
|
## 0.1.0 Initial release!
|
|
255
|
-
|
data/Gemfile
CHANGED
data/ISSUE_TEMPLATE.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
* On Windows? If so, do you need devkit for your ruby install?
|
|
4
4
|
* Using Ubuntu? If so, you may have forgotten to install FreeTDS first.
|
|
5
|
-
* Are you using FreeTDS 0.
|
|
5
|
+
* Are you using FreeTDS 1.0.0 or later? Check `$ tsql -C` to find out.
|
|
6
6
|
* If not, please update then uninstall the TinyTDS gem and re-install it.
|
|
7
7
|
* Have you made sure to [enable SQL Server authentication](http://bit.ly/1Kw3set)?
|
|
8
8
|
* Doing work with threads and the raw client? Use the ConnectionPool gem?
|
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,67 +18,69 @@ The API is simple and consists of these classes:
|
|
|
26
18
|
|
|
27
19
|
## Install
|
|
28
20
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
$ gem install tiny_tds
|
|
33
|
-
```
|
|
21
|
+
tiny_tds is tested with Ruby v2.7 and upwards.
|
|
34
22
|
|
|
35
|
-
|
|
36
|
-
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)
|
|
37
24
|
|
|
38
|
-
|
|
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
|
-
Our goal is to support every SQL Server data type and
|
|
83
|
+
Our goal is to support every SQL Server data type and convert 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 to the connection's encoding and all binary data types are associated to Ruby's `ASCII-8BIT/BINARY` encoding.
|
|
90
84
|
|
|
91
85
|
Below is a list of the data types we support when using the 7.3 TDS protocol version. Using a lower protocol version will result in these types being returned as strings.
|
|
92
86
|
|
|
@@ -104,18 +98,18 @@ Connect to a database.
|
|
|
104
98
|
client = TinyTds::Client.new username: 'sa', password: 'secret', host: 'mydb.host.net'
|
|
105
99
|
```
|
|
106
100
|
|
|
107
|
-
Creating a new client takes a hash of options. For valid iconv encoding options, see the output of `iconv -l`. Only a few have been tested and highly recommended to leave blank for the UTF-8 default.
|
|
101
|
+
Creating a new client takes a hash of options. For valid iconv encoding options, see the output of `iconv -l`. Only a few have been tested, and are highly recommended to leave blank for the UTF-8 default.
|
|
108
102
|
|
|
109
103
|
* :username - The database server user.
|
|
110
104
|
* :password - The user password.
|
|
111
|
-
* :dataserver - Can be the name for your data server as defined in freetds.conf. Raw hostname or hostname:port will work here too. FreeTDS says that named instance like 'localhost\SQLEXPRESS' work too, but I highly suggest that you use the :host and :port options below. [Google how to find your host port if you are using named instances](http://bit.ly/xAf2jm) or [go here](http://msdn.microsoft.com/en-us/library/ms181087.aspx).
|
|
105
|
+
* :dataserver - Can be the name for your data server as defined in freetds.conf. Raw hostname or hostname:port will work here too. FreeTDS says that a named instance like 'localhost\SQLEXPRESS' will work too, but I highly suggest that you use the :host and :port options below. [Google how to find your host port if you are using named instances](http://bit.ly/xAf2jm) or [go here](http://msdn.microsoft.com/en-us/library/ms181087.aspx).
|
|
112
106
|
* :host - Used if :dataserver blank. Can be an host name or IP.
|
|
113
107
|
* :port - Defaults to 1433. Only used if :host is used.
|
|
114
108
|
* :database - The default database to use.
|
|
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,47 +401,54 @@ 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
|
|
404
|
+
After that, the quickest way to get setup for development is to use the provided devcontainers setup.
|
|
428
405
|
|
|
429
406
|
```shell
|
|
430
|
-
|
|
407
|
+
npm install -g @devcontainers/cli
|
|
408
|
+
devcontainer up --workspace-folder .
|
|
409
|
+
devcontainer exec --workspace-folder . bash
|
|
431
410
|
```
|
|
432
411
|
|
|
433
|
-
|
|
412
|
+
From within the container, you can run the tests using the following command:
|
|
434
413
|
|
|
435
414
|
```shell
|
|
436
|
-
|
|
437
|
-
|
|
415
|
+
bundle install
|
|
416
|
+
bundle exec rake test
|
|
438
417
|
```
|
|
439
418
|
|
|
440
|
-
|
|
419
|
+
You can customize the environment variables to run the tests against a different environment
|
|
441
420
|
|
|
442
|
-
```
|
|
443
|
-
|
|
421
|
+
```shell
|
|
422
|
+
rake test TINYTDS_UNIT_DATASERVER=mydbserver TINYTDS_SCHEMA=sqlserver_2017
|
|
423
|
+
rake test TINYTDS_UNIT_HOST=mydb.host.net TINYTDS_SCHEMA=sqlserver_azure
|
|
444
424
|
```
|
|
445
425
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
```
|
|
426
|
+
### Code formatting
|
|
427
|
+
|
|
428
|
+
We are using `standardrb` to format the Ruby code and Artistic Style for the C code. Run `bundle exec rake format` to format both types in one operation. Artistic Style needs to be manually installed through your package manager (e.g. `apt install -y astyle`).
|
|
429
|
+
|
|
430
|
+
### Compiling Gems for Windows and Linux
|
|
452
431
|
|
|
453
|
-
|
|
432
|
+
> [!WARNING]
|
|
433
|
+
> Compiling the Gems on native Windows currently does not work.
|
|
434
|
+
|
|
435
|
+
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.
|
|
436
|
+
|
|
437
|
+
Run the following rake task to compile the gems. You can run these commands from inside the devcontainers setup, or outside if neeed. The command 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
438
|
|
|
455
439
|
```shell
|
|
456
|
-
|
|
457
|
-
$ bundle exec rake
|
|
440
|
+
bundle exec rake gem:native
|
|
458
441
|
```
|
|
459
442
|
|
|
460
|
-
|
|
443
|
+
The compiled gems will exist in `./pkg` directory.
|
|
461
444
|
|
|
445
|
+
If you only need a specific gem for one platform and architecture, run this command:
|
|
446
|
+
|
|
447
|
+
```shell
|
|
448
|
+
bundle exec rake gem:native:x64-mingw-ucrt
|
|
462
449
|
```
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
$ 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
|
-
```
|
|
450
|
+
|
|
451
|
+
All the supported architectures and platforms are listed in the `Rakefile` in the `CrossLibraries` constant.
|
|
468
452
|
|
|
469
453
|
## Help & Support
|
|
470
454
|
|
|
@@ -490,4 +474,4 @@ My name is Ken Collins and I currently maintain the SQL Server adapter for Activ
|
|
|
490
474
|
|
|
491
475
|
## License
|
|
492
476
|
|
|
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
|
|
477
|
+
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,47 @@ 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
68
|
|
|
69
|
+
task :format do
|
|
70
|
+
system("bundle exec standardrb --fix")
|
|
71
|
+
system('astyle --options=astyle.conf "./ext/*.c" "./ext/*.h"')
|
|
72
|
+
end
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
3.4.0
|