Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/sqlx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ jobs:
-p sqlx-sqlite
--all-features

- name: Install GSSAPI dev headers
run: sudo apt-get install -y libkrb5-dev

- name: Test sqlx-mssql
run: >
cargo test
Expand Down
8 changes: 4 additions & 4 deletions examples/mssql/todos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ edition = "2021"
workspace = "../../../"

[dependencies]
anyhow = "1.0"
anyhow = "1.0.58"
sqlx = { path = "../../../", features = [ "mssql", "runtime-tokio", "tls-native-tls" ] }
clap = { version = "4", features = ["derive"] }
tokio = { version = "1.20.0", features = ["rt", "macros"] }
dotenvy = "0.15.0"
clap = { version = "4.4.7", features = ["derive"] }
tokio = { version = "1.25.0", features = ["rt", "macros"]}
dotenvy = "0.15.7"
14 changes: 7 additions & 7 deletions sqlx-mssql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ uuid = ["dep:uuid", "sqlx-core/uuid"]
sqlx-core = { workspace = true }

# TDS protocol driver
tiberius = { version = "0.12", default-features = false, features = ["tds73"] }
tiberius = { version = "0.12.3", default-features = false, features = ["tds73"] }

# Futures crates
futures-core = { version = "0.3.19", default-features = false }
futures-io = "0.3.24"
futures-util = { version = "0.3.19", default-features = false, features = ["alloc", "sink", "io"] }
futures-core = { version = "0.3.32", default-features = false }
futures-io = "0.3.32"
futures-util = { version = "0.3.32", default-features = false, features = ["alloc", "sink", "io"] }

# Runtime bridging
tokio = { workspace = true, optional = true }
Expand All @@ -50,16 +50,16 @@ time = { workspace = true, optional = true }
uuid = { workspace = true, optional = true }

# Misc
bytes = "1.1.0"
bytes = "1.2.0"
either = "1.6.1"
log = "0.4.18"
tracing = { version = "0.1.37", features = ["log"] }
percent-encoding = "2.1.0"
percent-encoding = "2.3.0"

dotenvy.workspace = true
thiserror.workspace = true

serde = { version = "1.0.144", optional = true }
serde = { version = "1.0.219", optional = true }

[dev-dependencies]
# FIXME: https://github.com/rust-lang/cargo/issues/15622
Expand Down
11 changes: 10 additions & 1 deletion sqlx-mssql/src/advisory_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,17 @@ impl MssqlAdvisoryLock {
/// Returns `Ok(true)` if the lock was successfully released, `Ok(false)`
/// if the lock was not held by this session.
pub async fn release(&self, conn: &mut MssqlConnection) -> Result<bool, Error> {
// sp_releaseapplock raises error 1223 ("not currently held") instead
// of returning a status, so we catch it and map to status `-999`,
// which the match below already maps to `Ok(false)`.
let sql = "DECLARE @r INT; \
EXEC @r = sp_releaseapplock @Resource = @p1, @LockOwner = 'Session'; \
BEGIN TRY \
EXEC @r = sp_releaseapplock @Resource = @p1, @LockOwner = 'Session'; \
END TRY \
BEGIN CATCH \
IF ERROR_NUMBER() = 1223 SET @r = -999; \
ELSE THROW; \
END CATCH; \
SELECT @r;";

let status: i32 = query_scalar(sql)
Expand Down
16 changes: 7 additions & 9 deletions sqlx-mssql/src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ impl MssqlArguments {
where
T: Encode<'q, Mssql> + Type<Mssql>,
{
// Detect "encoder reported null without pushing" by comparing len()
// before and after — the previous check used `last() is Null`, which
// mistakenly dropped a Null bind whenever the previous parameter was
// also Null (e.g. `bind(None).bind(None)`).
let before = self.values.len();
let is_null = value.encode(&mut self.values)?;
if is_null.is_null() {
// If the encoder signaled null but didn't push a value, push a Null
if self
.values
.last()
.is_none_or(|v| !matches!(v, MssqlArgumentValue::Null))
{
self.values.push(MssqlArgumentValue::Null);
}
if is_null.is_null() && self.values.len() == before {
self.values.push(MssqlArgumentValue::Null);
}
Ok(())
}
Expand Down
Loading
Loading