Skip to main content

cratestack_sqlx/
sqlx.rs

1//! Compatibility shim that exposes a `sqlx`-shaped API by re-exporting from
2//! `sqlx-core` + `sqlx-postgres` directly.
3//!
4//! **Why this shim exists:** depending on the `sqlx` umbrella crate transitively
5//! pulls `sqlx-sqlite` into the resolve graph (Cargo's resolver materialises the
6//! optional dep even when no feature activates it), which pins `libsqlite3-sys
7//! ^0.30.1` and conflicts with `rusqlite 0.40`'s `libsqlite3-sys ^0.38` via the
8//! `links = "sqlite3"` rule. Going direct to the split crates side-steps the
9//! leak entirely. Downstream users keep writing `cratestack::sqlx::X` paths;
10//! macro emissions stay unchanged.
11//!
12//! **SemVer caveat:** `sqlx-core` documents itself as "not meant for general use"
13//! without SemVer guarantees. The surface re-exported here is the narrow subset
14//! the umbrella `sqlx` crate exposes, which was stable in practice across `0.8.x`
15//! and is now pinned at `=0.9.0`. That design paid off at the 0.8→0.9 boundary:
16//! upstream's `SqlSafeStr` bound and the `QueryBuilder` lifetime removal landed
17//! as *additions to this list* (`AssertSqlSafe`/`SqlSafeStr`/`SqlStr`) plus
18//! mechanical call-site edits, with no downstream `::cratestack::sqlx::…` path
19//! changing. Treat any future minor the same way: adapt here first.
20
21pub use sqlx_core::Either;
22pub use sqlx_core::acquire::Acquire;
23pub use sqlx_core::arguments::{Arguments, IntoArguments};
24pub use sqlx_core::column::{Column, ColumnIndex};
25pub use sqlx_core::connection::{ConnectOptions, Connection};
26pub use sqlx_core::database::{self, Database};
27pub use sqlx_core::describe::Describe;
28pub use sqlx_core::executor::{Execute, Executor};
29pub use sqlx_core::from_row::FromRow;
30pub use sqlx_core::pool::{self, Pool};
31pub use sqlx_core::query::{query, query_with};
32pub use sqlx_core::query_as::{query_as, query_as_with};
33pub use sqlx_core::query_builder::{self, QueryBuilder};
34pub use sqlx_core::query_scalar::{query_scalar, query_scalar_with};
35pub use sqlx_core::raw_sql::{RawSql, raw_sql};
36pub use sqlx_core::row::Row;
37// sqlx 0.9.0 (#3723) narrowed every `query*()`/`raw_sql()` entry point to
38// `impl SqlSafeStr`, implemented only for `&'static str` and the
39// `AssertSqlSafe` wrapper. Re-exported here rather than left to
40// `sqlx_core::sql_str::…` paths so the shim stays the single place that
41// knows which upstream module these live in — the same reason every other
42// item above is re-exported by name.
43pub use sqlx_core::sql_str::{AssertSqlSafe, SqlSafeStr, SqlStr};
44pub use sqlx_core::statement::Statement;
45pub use sqlx_core::transaction::{Transaction, TransactionManager};
46pub use sqlx_core::type_info::TypeInfo;
47pub use sqlx_core::value::{Value, ValueRef};
48
49pub use sqlx_core::error::{self, Error, Result};
50
51#[cfg(feature = "decimal-rust-decimal")]
52pub use sqlx_core::migrate;
53#[cfg(not(feature = "decimal-rust-decimal"))]
54pub use sqlx_core::migrate;
55
56pub use sqlx_postgres::{
57    self as postgres, PgConnection, PgExecutor, PgPool, PgTransaction, Postgres,
58};
59
60pub mod types {
61    pub use sqlx_core::types::*;
62}
63
64pub mod encode {
65    pub use sqlx_core::encode::{Encode, IsNull};
66}
67pub use self::encode::Encode;
68
69pub mod decode {
70    pub use sqlx_core::decode::Decode;
71}
72pub use self::decode::Decode;
73
74pub use sqlx_core::types::Type;