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 doc example to make it clear that ".returning()" does not preserve original order #3917

Conversation

greyblake
Copy link
Contributor

The current doc example implies, that the order of returned values are always preserved:

let inserted_names = diesel::insert_into(users)
    .values(&vec![name.eq("Timmy"), name.eq("Jimmy")])
    .returning(name)
    .get_results(&connection);
assert_eq!(Ok(vec!["Timmy".to_string(), "Jimmy".to_string()]), inserted_names);

But unfortunately it's not guaranteed (at least definitely not by PostgreSQL DB, which is used for this doc test).

See more: https://stackoverflow.com/questions/5439293/is-insert-returning-guaranteed-to-return-things-in-the-right-order

P.S.
Thank you for the nice and reliable piece of software ❤️

Copy link
Member

@weiznich weiznich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening this PR and improving the documentation 👍

(Tests will likely fail due to chronotope/chrono#1389, I will take care of that later on)

@greyblake
Copy link
Contributor Author

@weiznich Thank you!

@weiznich weiznich enabled auto-merge January 26, 2024 19:36
@weiznich weiznich added this pull request to the merge queue Jan 27, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 27, 2024
@weiznich weiznich added this pull request to the merge queue Jan 27, 2024
Merged via the queue into diesel-rs:master with commit d3f7099 Jan 27, 2024
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants