Skip to content

Commit aa43670

Browse files
committed
feat: Adds compile time feature vendored-unix-odbc
1 parent 0241911 commit aa43670

File tree

3 files changed

+135
-10
lines changed

3 files changed

+135
-10
lines changed

.github/workflows/test.yml

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ jobs:
2222
# Extract all files from installer
2323
- name: Install SQLite drivers
2424
run: |
25-
Invoke-WebRequest http://www.ch-werner.de/sqliteodbc/sqliteodbc_w64.exe -OutFile C:\sqliteodbc.exe
26-
7z x C:\sqliteodbc.exe -o"C:\Program Files\SQLite ODBC Driver for Win64"
27-
REG ADD "HKLM\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" /v "SQLite3 ODBC Driver" /t REG_SZ /d Installed /f
28-
REG ADD "HKLM\SOFTWARE\ODBC\ODBCINST.INI\SQLite3 ODBC Driver" /v "Driver" /t REG_SZ /d "C:\Program Files\SQLite ODBC Driver for Win64\sqlite3odbc.dll" /f
29-
REG ADD "HKLM\SOFTWARE\ODBC\ODBCINST.INI\SQLite3 ODBC Driver" /v "Setup" /t REG_SZ /d "C:\Program Files\SQLite ODBC Driver for Win64\sqlite3odbc.dll" /f
30-
REG ADD "HKLM\SOFTWARE\ODBC\ODBCINST.INI\SQLite3 ODBC Driver" /v "UsageCount" /t REG_DWORD /d 1
25+
Invoke-WebRequest http://www.ch-werner.de/sqliteodbc/sqliteodbc_w64.exe -OutFile C:\sqliteodbc.exe
26+
7z x C:\sqliteodbc.exe -o"C:\Program Files\SQLite ODBC Driver for Win64"
27+
REG ADD "HKLM\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" /v "SQLite3 ODBC Driver" /t REG_SZ /d Installed /f
28+
REG ADD "HKLM\SOFTWARE\ODBC\ODBCINST.INI\SQLite3 ODBC Driver" /v "Driver" /t REG_SZ /d "C:\Program Files\SQLite ODBC Driver for Win64\sqlite3odbc.dll" /f
29+
REG ADD "HKLM\SOFTWARE\ODBC\ODBCINST.INI\SQLite3 ODBC Driver" /v "Setup" /t REG_SZ /d "C:\Program Files\SQLite ODBC Driver for Win64\sqlite3odbc.dll" /f
30+
REG ADD "HKLM\SOFTWARE\ODBC\ODBCINST.INI\SQLite3 ODBC Driver" /v "UsageCount" /t REG_DWORD /d 1
3131
3232
# selecting a toolchain either by action or manual `rustup` calls should happen
3333
# before the plugin, as the cache uses the current rustc version as its cache key
@@ -117,10 +117,45 @@ jobs:
117117
cargo new test-compilation
118118
cd test-compilation
119119
cargo add odbc-api --path ../odbc-api/odbc-api --no-default-features --features odbc_version_3_5
120-
cargo build
120+
cargo build
121+
122+
vendored_unix_odbc_linux:
123+
name: Check build with vendored unixODBC on Linux
124+
runs-on: ubuntu-latest
125+
126+
services:
127+
sqlserver:
128+
image: mcr.microsoft.com/mssql/server:2019-latest
129+
ports:
130+
- 1433:1433
131+
env:
132+
ACCEPT_EULA: Y
133+
SA_PASSWORD: My@Test@Password1
134+
135+
postgres:
136+
image: postgres:18
137+
ports:
138+
- "5432:5432"
139+
env:
140+
POSTGRES_DB: test
141+
POSTGRES_USER: test
142+
POSTGRES_PASSWORD: test
143+
144+
steps:
145+
- name: Checkout
146+
uses: actions/checkout@v4
147+
- name: Install latests rust toolchain
148+
uses: actions-rs/toolchain@v1
149+
with:
150+
toolchain: stable
151+
default: true
152+
override: true
153+
- name: test
154+
run: |
155+
cargo test --features vendored-unix-odbc -- --skip maria_db
121156
122157
dependabot:
123-
needs: [linux,win64,osx,win32]
158+
needs: [linux, win64, osx, win32]
124159
permissions:
125160
pull-requests: write
126161
contents: write
@@ -131,4 +166,4 @@ jobs:
131166
run: gh pr merge --auto --rebase "$PR_URL"
132167
env:
133168
PR_URL: ${{github.event.pull_request.html_url}}
134-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
169+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

Cargo.lock

Lines changed: 82 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

odbc-api/Cargo.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ iodbc = ["odbc_version_3_5", "narrow", "odbc-sys/iodbc"]
7979
# Allows deriving custom implementations of `FetchRow` for row wise bulk fetching.
8080
derive = ["dep:odbc-api-derive"]
8181

82+
# Use this to build unixODBC as a dependency of odbc-sys and link statically againts it. This can
83+
# make installation of your artifact easier, because users may not need to install a driver manager.
84+
# However, please note that unixODBC is published under an LGPL license, so by statically linking
85+
# you need to take the implications for your artifact into account. `odbc-api` itself is MIT
86+
# licensed. In order to build unixODBC it draws in an optional dependency containing the unixODBC
87+
# source code, which is licensed under the same terms as unixODBC itself.
88+
vendored-unix-odbc = ["odbc-sys/vendored-unix-odbc"]
89+
8290
default = ["odbc_version_3_80", "prompt"]
8391

8492
# ODBC offers an interface to prompt the user for a connection string. This requires passing a
@@ -93,7 +101,7 @@ prompt = ["dep:winit"]
93101

94102
[dependencies]
95103
# Low level bindings to ODBC API calls into libodbc.so
96-
odbc-sys = { version = "0.27", default-features = false }
104+
odbc-sys = { version = "0.27.1", default-features = false }
97105
# Used to generate code for the error type
98106
thiserror = "2.0.17"
99107
# Used as a log frontend to emit log messages for applications

0 commit comments

Comments
 (0)