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.
Files changed (64) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +590 -0
  3. data/.gitignore +2 -0
  4. data/CHANGELOG.md +51 -1
  5. data/Gemfile +1 -8
  6. data/ISSUE_TEMPLATE.md +1 -1
  7. data/README.md +89 -89
  8. data/Rakefile +44 -30
  9. data/VERSION +1 -1
  10. data/docker-compose.yml +34 -0
  11. data/ext/tiny_tds/client.c +100 -59
  12. data/ext/tiny_tds/client.h +5 -3
  13. data/ext/tiny_tds/extconf.rb +173 -52
  14. data/ext/tiny_tds/extconsts.rb +4 -11
  15. data/ext/tiny_tds/result.c +52 -45
  16. data/ext/tiny_tds/tiny_tds_ext.c +4 -1
  17. data/lib/tiny_tds/bin.rb +12 -26
  18. data/lib/tiny_tds/client.rb +38 -42
  19. data/lib/tiny_tds/error.rb +0 -2
  20. data/lib/tiny_tds/gem.rb +5 -14
  21. data/lib/tiny_tds/result.rb +0 -2
  22. data/lib/tiny_tds/version.rb +1 -1
  23. data/lib/tiny_tds.rb +28 -47
  24. data/setup_cimgruby_dev.sh +25 -0
  25. data/start_dev.sh +21 -0
  26. data/tasks/native_gem.rake +12 -10
  27. data/tasks/package.rake +1 -3
  28. data/tasks/ports.rake +14 -77
  29. data/tasks/test.rake +3 -5
  30. data/test/bin/install-freetds.sh +2 -4
  31. data/test/bin/install-mssql.ps1 +42 -0
  32. data/test/bin/install-mssqltools.sh +9 -0
  33. data/test/bin/restore-from-native-gem.ps1 +10 -0
  34. data/test/bin/setup_tinytds_db.sh +7 -0
  35. data/test/bin/setup_volume_permissions.sh +10 -0
  36. data/test/client_test.rb +152 -116
  37. data/test/gem_test.rb +39 -118
  38. data/test/result_test.rb +285 -350
  39. data/test/schema_test.rb +369 -395
  40. data/test/sql/db-create.sql +18 -0
  41. data/test/sql/db-login.sql +38 -0
  42. data/test/test_helper.rb +112 -85
  43. data/test/thread_test.rb +22 -31
  44. data/tiny_tds.gemspec +28 -26
  45. metadata +85 -59
  46. data/.travis.yml +0 -24
  47. data/BACKERS.md +0 -32
  48. data/appveyor.yml +0 -51
  49. data/tasks/ports/freetds.rb +0 -37
  50. data/tasks/ports/libiconv.rb +0 -43
  51. data/tasks/ports/openssl.rb +0 -78
  52. data/tasks/ports/recipe.rb +0 -52
  53. data/test/appveyor/dbsetup.ps1 +0 -27
  54. data/test/appveyor/dbsetup.sql +0 -9
  55. data/test/benchmark/query.rb +0 -77
  56. data/test/benchmark/query_odbc.rb +0 -106
  57. data/test/benchmark/query_tinytds.rb +0 -126
  58. data/test/bin/setup.sh +0 -19
  59. data/test/schema/sqlserver_2000.sql +0 -140
  60. data/test/schema/sqlserver_2005.sql +0 -140
  61. data/test/schema/sqlserver_2014.sql +0 -140
  62. data/test/schema/sqlserver_2016.sql +0 -140
  63. data/test/schema/sybase_ase.sql +0 -138
  64. /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
- * [![TravisCI](https://travis-ci.org/rails-sqlserver/tiny_tds.svg?branch=master)](https://travis-ci.org/rails-sqlserver/tiny_tds) - TravisCI
4
- * [![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) - Appveyor
5
3
  * [![Gem Version](https://img.shields.io/gem/v/tiny_tds.svg)](https://rubygems.org/gems/tiny_tds) - Gem Version
6
- * [![Dependency Status](https://dependencyci.com/github/rails-sqlserver/tiny_tds/badge)](https://dependencyci.com/github/rails-sqlserver/tiny_tds) - Dependency Status
7
4
  * [![Gitter chat](https://img.shields.io/badge/%E2%8A%AA%20GITTER%20-JOIN%20CHAT%20%E2%86%92-brightgreen.svg?style=flat)](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 or Sybase databases from Ruby using the FreeTDS's DB-Library API.
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. The motivation for TinyTDS is to become the de-facto low level connection mode for the SQL Server Adapter for ActiveRecord.
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
- Installing with rubygems should just work. TinyTDS is currently tested on Ruby version 2.0.0 and upward.
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
- If you use Windows, we pre-compile TinyTDS with static versions of FreeTDS and supporting libraries.
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
- $ apt-get install wget
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
- 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:
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
- ## Getting Started
39
+ ### Mac
62
40
 
63
- Optionally, Microsoft has done a great job writing some articles on how to get started with SQL Server and Ruby using TinyTDS. Please checkout one of the following posts that match your platform.
41
+ Install FreeTDS via Homebrew:
64
42
 
65
- * [SQL Server on a Mac](https://www.microsoft.com/en-us/sql-server/developer-get-started/ruby/mac)
66
- * [SQL Server on RHEL](https://www.microsoft.com/en-us/sql-server/developer-get-started/ruby/rhel)
67
- * [SQL Server on Ubuntu](https://www.microsoft.com/en-us/sql-server/developer-get-started/ruby/ubuntu)
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
- ## FreeTDS Compatibility & Configuration
50
+ ```shell
51
+ gem install tiny_tds
52
+ ```
71
53
 
72
- TinyTDS is developed against FreeTDS 0.95, 0.99, and 1.0 current. Our default and recommended is 1.0. We also test with SQL Server 2008, 2014, and Azure. However, usage of TinyTDS with SQL Server 2000 or 2005 should be just fine. Below are a few QA style notes about installing FreeTDS.
54
+ ### Everybody else
73
55
 
74
- **NOTE:** Windows users of our pre-compiled native gems need not worry about installing FreeTDS and its dependencies.
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
- * **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.
58
+ ```shell
59
+ $ apt-get install wget
60
+ $ apt-get install build-essential
61
+ $ apt-get install libc6-dev
77
62
 
78
- * **OK, I am installing FreeTDS, how do I configure it?** Contrary to what most people think, you do not need to specially configure FreeTDS in any way for client libraries like TinyTDS to use it. About the only requirement is that you compile it with libiconv for proper encoding support. FreeTDS must also be compiled with OpenSSL (or the like) to use it with Azure. See the "Using TinyTDS with Azure" section below for more info.
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
- * **Do I need to configure `--with-tdsver` equal to anything?** Most likely! Technically you should not have too. This is only a default for clients/configs that do not specify what TDS version they want to use. We are currently having issues with passing down a TDS version with the login bit. Till we get that fixed, if you are not using a freetds.conf or a TDSVER environment variable, then make sure to use 7.1.
71
+ You can also tell `tiny_tds` where to find your FreeTDS installation.
81
72
 
82
- * **But I want to use TDS version 7.2 for SQL Server 2005 and up!** TinyTDS uses TDS version 7.1 (previously named 8.0) and fully supports all the data types supported by FreeTDS, this includes `varchar(max)` and `nvarchar(max)`. Technically compiling and using TDS version 7.2 with FreeTDS is not supported. But this does not mean those data types will not work. I know, it's confusing If you want to learn more, read this thread. http://lists.ibiblio.org/pipermail/freetds/2011q3/027306.html
73
+ ```shell
74
+ gem install tiny_tds -- --with-freetds-dir=/opt/freetds
75
+ ```
83
76
 
84
- * **I want to configure FreeTDS using `--enable-msdblib` and/or `--enable-sybase-compat` so it works for my database. Cool?** It's a waste of time and totally moot! Client libraries like TinyTDS define their own C structure names where they diverge from Sybase to SQL Server. Technically we use the MSDBLIB structures which does not mean we only work with that database vs Sybase. These configs are just a low level default for C libraries that do not define what they want. So I repeat, you do not NEED to use any of these, nor will they hurt anything since we control what C structure names we use internally!
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.3 TDS protocol version. Using a lower protocol version will result in these types being returned as strings.
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. Prior to 1.0rc5, FreeTDS was unable to set the timeout on a per-client basis, permitting only a global timeout value. This means that if you're using an older version, the timeout values for all clients will be overwritten each time you instantiate a new `TinyTds::Client` object. If you are using 1.0rc5 or later, all clients will have an independent timeout setting as you'd expect.
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](http://www.freetds.org/userguide/usefreetds.htm) 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.
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 using FreeTDS version 0.95 or higher. You must use the `use_utf16` login option or add the following config to your `freetds.conf` in either the global section or a specfic dataserver. If you are on Windows, the default location for your conf file will be in `C:\Sites`.
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 and you have , you can run our test setup script.
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
- $ ./test/bin/setup.sh
407
+ $ docker-compose up -d
431
408
  ```
432
409
 
433
- This will download our SQL Server for Linux Docker image based from [microsoft/mssql-server-linux/](https://hub.docker.com/r/microsoft/mssql-server-linux/). Our image already has the `[tinytdstest]` DB and `tinytds` users created. Basically, it does the following.
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 pull metaskills/mssql-server-linux-tinytds
437
- $ docker run -p 1433:1433 -d metaskills/mssql-server-linux-tinytds
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
- If you are using your own database. Make sure to run these SQL commands as SA to get the test database and user installed.
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
- ```sql
447
- CREATE LOGIN [tinytds] WITH PASSWORD = '', CHECK_POLICY = OFF, DEFAULT_DATABASE = [tinytdstest];
448
- USE [tinytdstest];
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=sqlserver_2008
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
- # encoding: UTF-8
2
- require 'rbconfig'
3
- require 'rake'
4
- require 'rake/clean'
5
- require 'rake/extensiontask'
6
- require_relative './ext/tiny_tds/extconsts'
7
-
8
- SPEC = Gem::Specification.load(File.expand_path('../tiny_tds.gemspec', __FILE__))
9
- GEM_PLATFORM_HOSTS = {
10
- 'x86-mingw32' => 'i686-w64-mingw32',
11
- 'x64-mingw32' => 'x86_64-w64-mingw32'
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['DLEXT']},o}"],
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['tasks/*.rake'].sort.each { |f| load f }
29
+ Dir["tasks/*.rake"].sort.each { |f| load f }
24
30
 
25
- Rake::ExtensionTask.new('tiny_tds', SPEC) do |ext|
26
- ext.lib_dir = 'lib/tiny_tds'
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 = GEM_PLATFORM_HOSTS.keys
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('msys2_mingw_dependencies')
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
- # We don't need the sources in a fat binary gem
40
- spec.files = spec.files.reject { |f| f =~ %r{^ports\/archives/} }
41
-
42
- # Make sure to include the ports binaries and libraries
43
- spec.files += FileList["ports/#{host}/**/**/{bin,lib}/*"].exclude do |f|
44
- File.directory? f
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
- spec.files += Dir.glob('exe/*')
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.2
1
+ 3.2.0
@@ -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"