We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8b52774 commit 838a239Copy full SHA for 838a239
sqlx-postgres/src/types/mod.rs
@@ -179,6 +179,18 @@
179
//! enum Mood { Sad = 0, Ok = 1, Happy = 2 }
180
//! ```
181
//!
182
+//! Rust enumerations may also be defined to be represented as a string using `type_name = "text"`.
183
+//! The following type expects a SQL type of `TEXT` and will convert to/from the Rust enumeration.
184
+//!
185
+//! ```rust,ignore
186
+//! #[derive(sqlx::Type)]
187
+//! #[sqlx(type_name = "text")]
188
+//! enum Mood { Sad, Ok, Happy }
189
+//! ```
190
191
+//! Note that an error can occur if you attempt to decode a value not contained within the enum
192
+//! definition.
193
194
195
use crate::type_info::PgTypeKind;
196
use crate::{PgTypeInfo, Postgres};
0 commit comments