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

Document code of sqlx::query_as has bugs. #3557

Open
xuehaonan27 opened this issue Oct 11, 2024 · 2 comments · May be fixed by #3558
Open

Document code of sqlx::query_as has bugs. #3557

xuehaonan27 opened this issue Oct 11, 2024 · 2 comments · May be fixed by #3558
Labels

Comments

@xuehaonan27
Copy link

Bug Description

In the document example code of sqlx::query_as, there exists several bugs that I encountered when testing.
query_as.rs: 230 mismatched bracket.
query_as.rs: 230 move TIMESTAMP to TIMESTAMPTZ to match type time::OffsetDateTime.
query_as.rs: 241, 251, 260 move i64 to i32 to match postgres type INT4.

Minimal Reproduction

Just run current code piece in document of query_as:
https://docs.rs/sqlx/latest/sqlx/fn.query_as.html#example-map-rows-using-tuples

Info

  • SQLx version: 0.8.2
  • SQLx features enabled: "runtime-tokio", "postgres", "time"
  • Database server and version: psql (PostgreSQL) 14.13 (Homebrew)
  • Operating system: MacOS Sonoma 14.5 23F79
  • rustc --version: rustc 1.81.0 (eeb90cda1 2024-09-04)
@xuehaonan27 xuehaonan27 linked a pull request Oct 11, 2024 that will close this issue
@benbot
Copy link

benbot commented Oct 11, 2024

I believe the Json example using query_as is also incorrect. It looks like macro returns Option<Json<T>> instead of Json<T> and Json<T> doesn't implement From<Option<Json<T>>>

https://docs.rs/sqlx/latest/sqlx/types/struct.Json.html

@xuehaonan27
Copy link
Author

I believe the Json example using query_as is also incorrect. It looks like macro returns Option<Json<T>> instead of Json<T> and Json<T> doesn't implement From<Option<Json<T>>>

https://docs.rs/sqlx/latest/sqlx/types/struct.Json.html

I will check it as well! Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants