oxide_sql_sqlite/
lib.rs

1//! # oxide-sql-sqlite
2//!
3//! SQLite-specific extensions for `oxide-sql-core`.
4//!
5//! # How SQLite differs from other dialects
6//!
7//! - **[UPSERT]**: SQLite supports
8//!   `INSERT ... ON CONFLICT DO NOTHING` and
9//!   `ON CONFLICT DO UPDATE SET ...` (since SQLite 3.24.0). This
10//!   crate provides [`UpsertBuilder`] for type-safe upsert
11//!   construction.
12//! - **[RETURNING]**: SQLite supports `RETURNING` clauses on
13//!   INSERT, UPDATE, and DELETE (since SQLite 3.35.0).
14//! - **Identifier quoting**: SQLite uses double quotes (`"`) as
15//!   the standard quoting style, though it also accepts backticks
16//!   and square brackets. See [SQLite keywords].
17//! - **[Type affinity]**: SQLite uses a type-affinity system rather
18//!   than strict column types. Any column can store any value
19//!   regardless of declared type (unless [`STRICT` tables] are
20//!   used).
21//! - **Limited [ALTER TABLE]**: SQLite only supports
22//!   `RENAME TABLE`, `RENAME COLUMN`, and `ADD COLUMN`. It does
23//!   not support `DROP COLUMN` (before 3.35.0), `ALTER COLUMN`,
24//!   or `ADD CONSTRAINT`.
25//! - **[AUTOINCREMENT]**: SQLite uses the `AUTOINCREMENT` keyword
26//!   (not sequences or `SERIAL` like PostgreSQL/DuckDB).
27//!
28//! [UPSERT]: https://www.sqlite.org/lang_upsert.html
29//! [RETURNING]: https://www.sqlite.org/lang_returning.html
30//! [SQLite keywords]: https://www.sqlite.org/lang_keywords.html
31//! [Type affinity]: https://www.sqlite.org/datatype3.html
32//! [`STRICT` tables]: https://www.sqlite.org/stricttables.html
33//! [ALTER TABLE]: https://www.sqlite.org/lang_altertable.html
34//! [AUTOINCREMENT]: https://www.sqlite.org/autoinc.html
35//!
36//! ## Example
37//!
38//! ```rust
39//! use oxide_sql_sqlite::UpsertBuilder;
40//! use oxide_sql_core::builder::value::ToSqlValue;
41//!
42//! // UPSERT example
43//! let (sql, params) = UpsertBuilder::new()
44//!     .into_table("users")
45//!     .columns(&["id", "name", "email"])
46//!     .values(vec![
47//!         1_i64.to_sql_value(),
48//!         "Alice".to_sql_value(),
49//!         "alice@example.com".to_sql_value(),
50//!     ])
51//!     .on_conflict(&["id"])
52//!     .do_update(&["name", "email"])
53//!     .build();
54//! ```
55
56pub mod builder;
57mod dialect;
58
59pub use builder::UpsertBuilder;
60pub use dialect::SqliteDialect;