Skip to content

Adding in generic connection trait back to the lib #525

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

Merged
merged 5 commits into from
Jan 3, 2020

Conversation

colingm
Copy link
Contributor

@colingm colingm commented Dec 21, 2019

I am trying to add back in the generic connection trait that existed for connections and traits in version 0.15.2 but was not put back in when this lib was rebuilt. This work is based on an existing closed PR: #433. I wasn't exactly sure where to put the generic connection so I added it in a new file but it could easily be moved to the lib.rs or even client.rs. I also used the old name of GenericConnection instead of GenericClient used in the old PR. All available feedback is requested.

fn query(&mut self, query: &str, params: &[&(dyn ToSql + Sync)]) -> Result<Vec<Row>, Error> {
self.query(query, params)
}
fn prepare(&mut self, query: &str) -> Result<Statement, Error> {
Copy link
Owner

Choose a reason for hiding this comment

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

It seems strange that you can prepare a statement but not use it through this interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops sorry I didn't even realize that query (and execute) had a generic, I have updated them to include the same trait and generic as the normal implementations

Copy link
Owner

Choose a reason for hiding this comment

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

That does mean that the trait isn't object safe, if that's relevant for what you're trying to do with it.

@sfackler sfackler merged commit 6deef22 into sfackler:master Jan 3, 2020
dvic added a commit to dvic/rust-postgres that referenced this pull request Jan 27, 2020
This add `execute_raw`,  `query_one`, `query_opt`, `query_raw`,
and `prepare_typed` to the generic trait introduced in sfackler#525.
dvic added a commit to dvic/rust-postgres that referenced this pull request Jan 27, 2020
This adds `execute_raw`,  `query_one`, `query_opt`, `query_raw`,
and `prepare_typed` to the generic trait introduced in sfackler#525.
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