Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign up`connection.query_one/all` with `update` and `delete` are a bit annoying to use #29
Comments
sgrif
added this to the 0.2 milestone
Nov 29, 2015
sgrif
added
enhancement
discussion desired
labels
Nov 29, 2015
sgrif
referenced this issue
Nov 29, 2015
Closed
`insert` is inconsistent, and should be changed to match other operations #30
This comment has been minimized.
|
I think once we add these methods, it'll also be fine to have |
added a commit
that referenced
this issue
Nov 29, 2015
sgrif
added
the
accepted
label
Nov 29, 2015
sgrif
modified the milestones:
0.3,
0.2
Nov 30, 2015
This comment has been minimized.
|
I am a little confused about where the API is going to end up after this and #30. The pattern that I am hoping it ends up is building the command and calling an execute/run/run_all/load function on that command for all database interactions. Something like:
Either that or calling all of them off of the connection themselves. |
This comment has been minimized.
|
@mfpiccolo You just described exactly what I want (Although I'm still unsure if |
This comment has been minimized.
|
also I'm leaning towards |
This comment has been minimized.
|
Yeah. That is more semantic. Will delete also support?:
|
This comment has been minimized.
|
It'll likely just be |
This comment has been minimized.
|
|
sgrif commentedNov 29, 2015
It used to be the case that everything had to go through
Connection#query_allandConnection#query_one. I found it was annoying, and added too many parenthesis, which is whyloadandfirstwere added. (connection.query_all(users.filter(name.eq("Sean")))vsusers.filter(name.eq("Sean")).load(&connection).I want to give the same treatment to these (technically
loadactually works fine, but I think thatupdate(users.filter(id.eq(1))).set(name.eq("Sean")).load(&connection)reads really strangely). We should add some new methods (the names are up for debate):run(&connection): We often know that we will return exactly one row. The should returnQueryResult<T>, and will basically beload(&connection).map(|mut r| r.nth(0).unwrap()).run_all(&connection): Alias forload. Probably a better name for this, but I want it to imply that we're doing a command that happens to return.execute(&connection): Alias forConnection#execute_returning_count