Skip to content

Commit 1b94e1d

Browse files
duhbyabonander
andauthored
chore(doc): clarify compile-time verification and case conversion behavior (#3866)
* chore(doc): clarify compile-time verification and case conversion behavior * apply review suggestions Co-authored-by: Austin Bonander <austin.bonander@gmail.com> * fix(fmt): remove trailing spaces * fix(doc): links --------- Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
1 parent 92c3845 commit 1b94e1d

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

sqlx-core/src/from_row.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ use crate::{error::Error, row::Row};
6565
/// reason), `lowercase`, `UPPERCASE`, `camelCase`, `PascalCase`, `SCREAMING_SNAKE_CASE` and `kebab-case`.
6666
/// The styling of each option is intended to be an example of its behavior.
6767
///
68+
/// Case conversion is handled by the `heck` crate.
69+
/// See [its documentation](https://docs.rs/heck/0.5.0/heck/#definition-of-a-word-boundary)
70+
/// for details.
71+
///
72+
/// Note that numbers are *not* considered separate words.
73+
/// For example, `Foo1` to snake case would be `foo1`, *not* `foo_1`.
74+
/// See [this issue](https://github.com/launchbadge/sqlx/issues/3864) for discussion.
75+
///
6876
/// #### `default`
6977
///
7078
/// When your struct contains a field that is not present in your query,

sqlx-core/src/types/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,11 @@ pub use bstr::{BStr, BString};
9999
///
100100
/// ## Compile-time verification
101101
///
102-
/// With compile-time verification, the use of type overrides is currently required to make
103-
/// use of any user-defined types.
102+
/// Type definitions are *not* verified against the database at compile-time.
103+
/// The [`query!()`](macro.query.html) macros have no implicit knowledge of user-defined types.
104+
///
105+
/// When using custom types in query parameters or output columns with `query!()`,
106+
/// the use of [type overrides](macro.query.html#type-overrides-bind-parameters-postgres-only) is required.
104107
///
105108
/// ```rust,ignore
106109
/// struct MyUser { id: UserId, name: String }

src/macros/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@
249249
///
250250
/// ##### Force a Different/Custom Type
251251
/// Selecting a column `foo as "foo: T"` (Postgres / SQLite) or `` foo as `foo: T` `` (MySQL)
252-
/// overrides the inferred type which is useful when selecting user-defined custom types
252+
/// overrides the inferred type which is useful when selecting user-defined [custom types][crate::Type#compile-time-verification]
253253
/// (dynamic type checking is still done so if the types are incompatible this will be an error
254254
/// at runtime instead of compile-time). Note that this syntax alone doesn't override inferred nullability,
255255
/// but it is compatible with the forced not-null and forced nullable annotations:

0 commit comments

Comments
 (0)