Expand description
SQL Server support via a hand-written [larust_repository::Repository]
implementation, one per model - not a larust_orm::Backend
variant. sqlx has no Microsoft SQL Server driver at all (confirmed by
reading its own source during this crate’s design: sqlx-core’s only
MSSQL-shaped code is permanently-dead, pre-0.8 scaffolding, and no
mssql Cargo feature has ever existed to enable it), so SQL Server
structurally cannot join the sqlx::Any/Backend/QueryBuilder
architecture the way SQLite/MySQL/Postgres do. This crate connects
through tiberius - a separate, pure-Rust TDS-protocol client with
its own connection type, its own @P1/@P2 parameter syntax, and no
shared code with larust-orm at all.
Explicit ceiling, stated plainly, not oversold: CRUD only. No
#[derive(Model)] codegen, no relations, no xr migrate, no
QueryBuilder-style chaining - the same trade-off
larust_repository::Repository’s own doc comment already documents
for “a backend sqlx::Any structurally cannot reach.” This crate owns
only the connection plumbing below; writing an actual Repository<T>
implementation for your own model is real, per-model code you write by
hand - there is no generic blanket impl<T> Repository<T> for AnyRepository<T> the way larust-orm has for SQL-family backends,
for the same reason that type’s own doc comment gives: building
INSERT/UPDATE text (or here, tiberius parameter bindings) from a
struct’s fields needs to know those fields, which a function generic
over T never does - only code written for that specific struct
can. See tests/widget_repository.rs for a complete worked example
against a real server, mirroring larust-repository’s own
InMemoryRepository test in shape, just against tiberius instead of
a HashMap.
The connection is a single, mutex-serialized tiberius::Client,
not a real pool - tiberius has no built-in pooling. This
serializes all SQL Server traffic in a process through one TDS
session, a real and deliberately undisguised limitation for this first
cut, not a glossed-over one. A proper pool (bb8/deadpool plus a
hand-written tiberius adapter) is the natural follow-up if concurrent
load against SQL Server ever becomes a real requirement - explicitly
out of scope here.
Re-exports§
pub use tiberius;
Structs§
- Mssql
Config - SQL Server connection settings - the same host/port/database/username/
password shape
larust_orm::config::ConnectionConfiguses for the SQL-family backends, but deliberately not that type itself:tiberiusdoesn’t take a connection URL the waysqlxdoes, it takes its owntiberius::Configbuilder, so there’s no sharedto_url()-style assembly to reuse here.
Functions§
- client
- Returns the process-wide client, locked for exclusive use - released
automatically when the returned guard drops. See this crate’s own doc
comment for why this is one mutex-serialized connection, not a pool.
Errors (rather than panics) if
connecthasn’t run yet - the same “a misconfigured startup order is a real possibility” reasoninglarust_orm::pool()already documents for its own identical case. - connect
- Connects and stores the client process-wide - same
OnceCellsingleton idiomlarust_orm::pool()’s ownOnceLock<AnyPool>uses. Call once at startup, before anyRepository<T>implementation built onclientruns.
Type Aliases§
- Mssql
Client - The concrete client type
clienthands back, locked.Compat< TcpStream>istiberius’s own transport-agnosticClientrunning over a plain Tokio TCP stream via thetokio-utilcompatibility shim (tiberiusis built against thefuturesAsyncRead/AsyncWritetraits, not Tokio’s own).