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
Provide get_optional #4
Comments
This is straight-forward - I can add this later today. |
I looked into this. What struct are you wanting I (believe I) just fixed the docs issue, though it seems like it takes time for changes to propagate from crate to docs.rs. Once it does though, hopefully the API will be more discoverable. |
Do I understand correctly that SelectQueryBuilder is e.g. select()? Then
vs
IMHO the second one is far easier to grasp. |
Yeah, that first query is how to do it with the current API. To confirm, the current It could make sense to add this API. I'm confused how common this use case is though. What's the scenario where you want to get an id, but you're not sure if it exists yet? (How would you even have the ID value?) |
Yep.
Sometimes ID is not an ID but a slug or a name. |
Why would the pkey field be the slug or name? That seems quite brittle, e.g. if you need to change an article's title. |
However if you have a list of servers that must have unique names this simplifies the API. |
You're presenting multiple examples, which makes me think you're talking about hypothetical requirements, rather than trying to solve a problem you're actively encountering as you build a service. We strive to build the API based on real-world usage. Unless you're in that situation, I'm going to push off further discussion on an API like you're suggesting here. |
Nah, I'm asking because that's what I'm missing writing a server. It's not a web service and one of the main route to use it is via CLI. So basically when user types |
However, you may be right that there are better ways to do what I want. I'm going to close it. |
Since there is no easy way to check why sqlx query failed it would be nice to have something similar to https://docs.rs/sqlx/0.5.10/sqlx/trait.Executor.html#tymethod.fetch_optional
The text was updated successfully, but these errors were encountered: