Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix example code of query_as #3558

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions sqlx-core/src/query_as.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ where
/// let mut conn: PgConnection = PgConnection::connect("<Database URL>").await?;
///
/// sqlx::raw_sql(
/// "CREATE TABLE users(id INTEGER PRIMARY KEY, username TEXT UNIQUE, created_at TIMESTAMP DEFAULT (now())"
/// "CREATE TABLE users(id INTEGER PRIMARY KEY, username TEXT UNIQUE, created_at TIMESTAMPTZ DEFAULT (now()))"
/// )
/// .execute(&mut conn)
/// .await?;
Expand All @@ -238,7 +238,7 @@ where
///
/// // Get the first row of the result (note the `LIMIT 1` for efficiency)
/// // This assumes the `time` feature of SQLx is enabled.
/// let oldest_user: (i64, String, time::OffsetDateTime) = sqlx::query_as(
/// let oldest_user: (i32, String, time::OffsetDateTime) = sqlx::query_as(
/// "SELECT id, username, created_at FROM users ORDER BY created_at LIMIT 1"
/// )
/// .fetch_one(&mut conn)
Expand All @@ -248,7 +248,7 @@ where
/// assert_eq!(oldest_user.1, "alice");
///
/// // Get at most one row
/// let maybe_charlie: Option<(i64, String, time::OffsetDateTime)> = sqlx::query_as(
/// let maybe_charlie: Option<(i32, String, time::OffsetDateTime)> = sqlx::query_as(
/// "SELECT id, username, created_at FROM users WHERE username = 'charlie'"
/// )
/// .fetch_optional(&mut conn)
Expand All @@ -257,7 +257,7 @@ where
/// assert_eq!(maybe_charlie, None);
///
/// // Get all rows in result (Beware of the size of the result set! Consider using `LIMIT`)
/// let users: Vec<(i64, String, time::OffsetDateTime)> = sqlx::query_as(
/// let users: Vec<(i32, String, time::OffsetDateTime)> = sqlx::query_as(
/// "SELECT id, username, created_at FROM users ORDER BY id"
/// )
/// .fetch_all(&mut conn)
Expand Down