Skip to content

refactor(sqlserver): use bridge preview.5 Value ToSql, drop value_to_sql_param workaround#212

Merged
debba merged 2 commits into
TabularisDB:feat/sql-serverfrom
saurabh500:agents/branch-status-update
May 19, 2026
Merged

refactor(sqlserver): use bridge preview.5 Value ToSql, drop value_to_sql_param workaround#212
debba merged 2 commits into
TabularisDB:feat/sql-serverfrom
saurabh500:agents/branch-status-update

Conversation

@saurabh500
Copy link
Copy Markdown
Contributor

Summary

Upgrades mssql-tiberius-bridge from preview.3 to preview.5 and removes the value_to_sql_param() workaround that was added in the issue #145 composite PK implementation.

Background

The bridge's impl ToSql for serde_json::Value previously called self.to_string() on every variant, which:

  • JSON-quoted strings: Value::String("alice") was bound as "\"alice\"" — matching zero DB rows
  • Stringified nulls: Value::Null was bound as "null" instead of SQL NULL

A local workaround value_to_sql_param() dispatched by variant to fix this. The fix was filed as bridge issue #95 and shipped in preview.5 (PR #96).

Changes

  • Cargo.toml: bump mssql-tiberius-bridge = "=0.1.0-preview.5"
  • sqlserver/helpers.rs: remove value_to_sql_param(), its ToSql import, and 6 now-redundant unit tests
  • sqlserver/mod.rs: simplify parameter binding — no more Box<dyn ToSql + Send + Sync> intermediate vec or &**b double-deref:
    • Delete: pk_vals.iter().map(|v| v as &dyn ToSql)
    • Update: once(&new_val).chain(pk_vals.iter()).map(|v| v as &dyn ToSql)

Tests

All 112 SQL Server driver tests pass.

Closes #145

saurabh500 and others added 2 commits May 18, 2026 06:52
…lue ToSql

The bridge's impl ToSql for serde_json::Value now dispatches by variant
(preview.5, fix TabularisDB#96): Null -> SQL NULL, Bool -> Bit, Number -> BigInt/Float,
String -> NVarchar (inner string, no JSON quotes), Array/Object -> NVarchar JSON.

- Bump mssql-tiberius-bridge to =0.1.0-preview.5
- Remove value_to_sql_param() workaround + its 6 unit tests from helpers.rs
- Remove the ToSql import from helpers.rs (no longer needed there)
- Simplify delete_record_composite: pk_vals.iter().map(|v| v as &dyn ToSql)
- Simplify update_record_composite: once(&new_val).chain(pk_vals.iter())
  No more Box<dyn ToSql + Send + Sync> intermediate collection

Closes companion bridge issue: saurabh500/mssql-tiberius-bridge#95

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…isDB#145)

Adds the missing TabularisDB#145 pieces alongside the SQL Server overrides:

- driver_trait.rs: delete_record_composite / update_record_composite
  default methods that forward to legacy single-key methods when
  pk_cols.len() == 1. Keeps MySQL/Postgres/SQLite drivers working
  byte-identically.
- commands.rs: extend update_record / delete_record Tauri commands
  with optional pk_cols / pk_vals. Routes to *_composite when present,
  legacy single-key path otherwise. Existing frontend callers unaffected
  (missing JSON keys deserialize to None).
- sqlite/tests.rs: regression tests for the single-key fallback path,
  ensuring MySQL/Postgres/SQLite behavior is preserved.
- integration_tests.rs: wire new test module.

Closes TabularisDB#145

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@saurabh500
Copy link
Copy Markdown
Contributor Author

@debba THis is ready for review

@debba debba merged commit 58c7ad2 into TabularisDB:feat/sql-server May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants