Skip to content

Commit 25f8385

Browse files
committed
make odbc mandatory
1 parent 515005c commit 25f8385

File tree

3 files changed

+28
-41
lines changed

3 files changed

+28
-41
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ lto = "fat"
1717
panic = "abort"
1818
codegen-units = 2
1919

20-
[features]
21-
# Build variants
22-
# - default (odbc-dynamic): ODBC enabled, dynamically linked (works on Linux, macOS, Windows)
23-
# - odbc-static: ODBC enabled, statically linked to the driver manager (Linux only)
24-
# - disable ODBC entirely: use `--no-default-features`
25-
default = ["odbc-dynamic"]
26-
odbc = ["sqlx/odbc"]
27-
odbc-dynamic = ["odbc"]
28-
odbc-static = ["odbc", "odbc-sys/static"]
29-
3020
[dependencies]
3121
sqlx = { package = "sqlx-oldapi", git = "https://github.com/sqlpage/sqlx-oldapi", version = "0.6.49-beta.6", default-features = false, features = [
3222
"any",
@@ -36,6 +26,7 @@ sqlx = { package = "sqlx-oldapi", git = "https://github.com/sqlpage/sqlx-oldapi"
3626
"postgres",
3727
"mysql",
3828
"mssql",
29+
"odbc",
3930
"chrono",
4031
"bigdecimal",
4132
"json",
@@ -84,13 +75,15 @@ clap = { version = "4.5.17", features = ["derive"] }
8475
tokio-util = "0.7.12"
8576
openidconnect = { version = "4.0.0", default-features = false }
8677
encoding_rs = "0.8.35"
87-
odbc-sys = { version = "0.27", optional = true }
8878

8979
[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies]
90-
odbc-sys = { version = "0.27", optional = true, features = ["iodbc", "static"] }
80+
odbc-sys = { version = "0.27", features = ["iodbc", "static"] }
81+
82+
[target.'cfg(any(target_os = "windows"))'.dependencies]
83+
odbc-sys = { version = "0.27", features = ["iodbc", "static"] }
9184

9285
[patch.crates-io]
93-
odbc-sys = { git = "https://github.com/sqlpage/odbc-sys", branch = "main" }
86+
odbc-sys = { git = "https://github.com/sqlpage/odbc-sys", branch = "main" } # see https://github.com/pacman82/odbc-sys/pull/60
9487

9588
[build-dependencies]
9689
awc = { version = "3", features = ["rustls-0_23-webpki-roots"] }

src/webserver/database/connect.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::{
88
};
99
use anyhow::Context;
1010
use futures_util::future::BoxFuture;
11-
#[cfg(feature = "odbc")]
1211
use sqlx::odbc::OdbcConnectOptions;
1312
use sqlx::{
1413
any::{Any, AnyConnectOptions, AnyKind},
@@ -210,11 +209,9 @@ fn set_custom_connect_options(options: &mut AnyConnectOptions, config: &AppConfi
210209
if let Some(sqlite_options) = options.as_sqlite_mut() {
211210
set_custom_connect_options_sqlite(sqlite_options, config);
212211
}
213-
#[cfg(feature = "odbc")]
214-
{
215-
if let Some(odbc_options) = options.as_odbc_mut() {
216-
set_custom_connect_options_odbc(odbc_options, config);
217-
}
212+
213+
if let Some(odbc_options) = options.as_odbc_mut() {
214+
set_custom_connect_options_odbc(odbc_options, config);
218215
}
219216
}
220217

@@ -243,7 +240,6 @@ fn make_sqlite_fun(name: &str, f: fn(&str) -> String) -> Function {
243240
})
244241
}
245242

246-
#[cfg(feature = "odbc")]
247243
fn set_custom_connect_options_odbc(odbc_options: &mut OdbcConnectOptions, config: &AppConfig) {
248244
// Allow fetching very large text fields when using ODBC by removing the max column size limit
249245
let batch_size = config.max_pending_rows.clamp(1, 1024);

0 commit comments

Comments
 (0)