From 41bf5e30eeea1b9dbf41286000c32f1cfd2381cb Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Thu, 23 Jul 2020 20:19:08 -0700 Subject: [PATCH] docs(macros): mention interpreting `EXPLAIN` output for SQLite Signed-off-by: Austin Bonander --- src/macros.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index d5e9d27f..87551283 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -101,7 +101,7 @@ /// In most cases, the database engine can tell us whether or not a column may be `NULL`, and /// the `query!()` macro adjusts the field types of the returned struct accordingly. /// -/// For Postgres and SQLite, this only works for columns which come directly from actual tables, +/// For Postgres, this only works for columns which come directly from actual tables, /// as the implementation will need to query the table metadata to find if a given column /// has a `NOT NULL` constraint. Columns that do not have a `NOT NULL` constraint or are the result /// of an expression are assumed to be nullable and so `Option` is used instead of `T`. @@ -115,6 +115,10 @@ /// `NULL` which then depends on the semantics of what functions are used. Consult the MySQL /// manual for the functions you are using to find the cases in which they return `NULL`. /// +/// For SQLite we perform a similar check to Postgres, looking for `NOT NULL` constraints +/// on columns that come from tables. However, for SQLite we also can step through the output +/// of `EXPLAIN` to identify columns that may or may not be `NULL`. +/// /// To override the nullability of an output column, [see below](#type-overrides-output-columns). /// /// ## Type Overrides: Bind Parameters (Postgres only) @@ -227,15 +231,11 @@ /// .fetch_one(&mut conn) /// .await?; /// -/// // For Postgres this would have been inferred to be `Option`, MySQL `i32` -/// // and SQLite it wouldn't have worked at all because we couldn't know the type. +/// // For Postgres this would have been inferred to be `Option`, MySQL/SQLite `i32` /// assert_eq!(record.id, MyInt4(1)); /// # } /// ``` /// -/// As mentioned, this allows specifying the type of a pure expression column which is normally -/// forbidden for SQLite as there's no way we can ask SQLite what type the column is expected to be. -/// /// ## Offline Mode (requires the `offline` feature) /// The macros can be configured to not require a live database connection for compilation, /// but it requires a couple extra steps: