From 228605ecbc57f28eba27efb6aa7bdbaee87eec78 Mon Sep 17 00:00:00 2001 From: tison Date: Thu, 26 Dec 2024 20:58:21 +0800 Subject: [PATCH 1/3] docs: add example for postgres enums with type TEXT Signed-off-by: tison --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- CONTRIBUTING.md | 2 +- README.md | 2 +- gen-changelog.sh | 2 +- sqlx-core/src/query_builder.rs | 2 +- sqlx-postgres/src/types/mod.rs | 8 ++++++++ 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 12a71c650b..3c86a03d81 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -9,7 +9,7 @@ assignees: '' A clear and concise description of what the bug is. ### Minimal Reproduction -A small code snippet or a link to a Github repo or Gist, with instructions on reproducing the bug. +A small code snippet or a link to a GitHub repo or Gist, with instructions on reproducing the bug. ### Info * SQLx version: [REQUIRED] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e0fdfe8890..99c6958d3b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,4 +41,4 @@ Additionally, it's always good to work on improving/adding examples and document If you're unsure about your contribution or simply want to ask a question about anything, you can: - Visit the [SQLx Discord server](https://discord.gg/uuruzJ7) -- Discuss something directly in the [Github issue](https://github.com/launchbadge/sqlx/issues). +- Discuss something directly in the [GitHub issue](https://github.com/launchbadge/sqlx/issues). diff --git a/README.md b/README.md index 4d4a2338ec..d9d5164270 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@
- + actions status diff --git a/gen-changelog.sh b/gen-changelog.sh index d0b9ba71f5..6c1da5fa1b 100755 --- a/gen-changelog.sh +++ b/gen-changelog.sh @@ -1,4 +1,4 @@ -# Requires Github CLI and `jq` +# Requires GitHub CLI and `jq` # Usage: `./gen-changelog.sh YYYY-mm-dd` # Generates changelog entries for all PRs merged on or after the given date. set -e diff --git a/sqlx-core/src/query_builder.rs b/sqlx-core/src/query_builder.rs index 0d02048dcf..acda4355a8 100644 --- a/sqlx-core/src/query_builder.rs +++ b/sqlx-core/src/query_builder.rs @@ -134,7 +134,7 @@ where /// * Postgres and MySQL: 65535 /// * You may find sources that state that Postgres has a limit of 32767, /// but that is a misinterpretation of the specification by the JDBC driver implementation - /// as discussed in [this Github issue][postgres-limit-issue]. Postgres itself + /// as discussed in [this GitHub issue][postgres-limit-issue]. Postgres itself /// asserts that the number of parameters is in the range `[0, 65535)`. /// * SQLite: 32766 (configurable by [`SQLITE_LIMIT_VARIABLE_NUMBER`]) /// * SQLite prior to 3.32.0: 999 diff --git a/sqlx-postgres/src/types/mod.rs b/sqlx-postgres/src/types/mod.rs index 26feb05580..bbf93d21ba 100644 --- a/sqlx-postgres/src/types/mod.rs +++ b/sqlx-postgres/src/types/mod.rs @@ -179,6 +179,14 @@ //! enum Mood { Sad = 0, Ok = 1, Happy = 2 } //! ``` //! +//! Rust enumerations may also be defined to be represented as a string using `type_name = "text"`. +//! The following type expects a SQL type of `TEXT` and will convert to/from the Rust enumeration. +//! +//! ```rust,ignore +//! #[derive(sqlx::Type)] +//! #[sqlx(type_name = "text")] +//! enum Mood { Sad, Ok, Happy } +//! ``` use crate::type_info::PgTypeKind; use crate::{PgTypeInfo, Postgres}; From 9a1138d14984a2c87aaa07097c80d47f6e058040 Mon Sep 17 00:00:00 2001 From: tison Date: Sat, 4 Jan 2025 15:46:44 +0800 Subject: [PATCH 2/3] revert GitHub naming Signed-off-by: tison --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- CONTRIBUTING.md | 2 +- README.md | 2 +- gen-changelog.sh | 2 +- sqlx-core/src/query_builder.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 3c86a03d81..12a71c650b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -9,7 +9,7 @@ assignees: '' A clear and concise description of what the bug is. ### Minimal Reproduction -A small code snippet or a link to a GitHub repo or Gist, with instructions on reproducing the bug. +A small code snippet or a link to a Github repo or Gist, with instructions on reproducing the bug. ### Info * SQLx version: [REQUIRED] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 99c6958d3b..e0fdfe8890 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,4 +41,4 @@ Additionally, it's always good to work on improving/adding examples and document If you're unsure about your contribution or simply want to ask a question about anything, you can: - Visit the [SQLx Discord server](https://discord.gg/uuruzJ7) -- Discuss something directly in the [GitHub issue](https://github.com/launchbadge/sqlx/issues). +- Discuss something directly in the [Github issue](https://github.com/launchbadge/sqlx/issues). diff --git a/README.md b/README.md index d9d5164270..4d4a2338ec 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@
- + actions status diff --git a/gen-changelog.sh b/gen-changelog.sh index 6c1da5fa1b..d0b9ba71f5 100755 --- a/gen-changelog.sh +++ b/gen-changelog.sh @@ -1,4 +1,4 @@ -# Requires GitHub CLI and `jq` +# Requires Github CLI and `jq` # Usage: `./gen-changelog.sh YYYY-mm-dd` # Generates changelog entries for all PRs merged on or after the given date. set -e diff --git a/sqlx-core/src/query_builder.rs b/sqlx-core/src/query_builder.rs index acda4355a8..0d02048dcf 100644 --- a/sqlx-core/src/query_builder.rs +++ b/sqlx-core/src/query_builder.rs @@ -134,7 +134,7 @@ where /// * Postgres and MySQL: 65535 /// * You may find sources that state that Postgres has a limit of 32767, /// but that is a misinterpretation of the specification by the JDBC driver implementation - /// as discussed in [this GitHub issue][postgres-limit-issue]. Postgres itself + /// as discussed in [this Github issue][postgres-limit-issue]. Postgres itself /// asserts that the number of parameters is in the range `[0, 65535)`. /// * SQLite: 32766 (configurable by [`SQLITE_LIMIT_VARIABLE_NUMBER`]) /// * SQLite prior to 3.32.0: 999 From bca3e45cf662a992997668ca88cd854a3aef0b34 Mon Sep 17 00:00:00 2001 From: tison Date: Sat, 4 Jan 2025 16:02:40 +0800 Subject: [PATCH 3/3] add note Signed-off-by: tison --- sqlx-postgres/src/types/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sqlx-postgres/src/types/mod.rs b/sqlx-postgres/src/types/mod.rs index bbf93d21ba..747345518a 100644 --- a/sqlx-postgres/src/types/mod.rs +++ b/sqlx-postgres/src/types/mod.rs @@ -187,6 +187,10 @@ //! #[sqlx(type_name = "text")] //! enum Mood { Sad, Ok, Happy } //! ``` +//! +//! Note that an error can occur if you attempt to decode a value not contained within the enum +//! definition. +//! use crate::type_info::PgTypeKind; use crate::{PgTypeInfo, Postgres};