Skip to content

Copy API improvement (#1536) #1537

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 2 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions sqlx-core/src/postgres/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ impl Pool<Postgres> {
/// ### Note
/// [PgCopyIn::finish] or [PgCopyIn::abort] *must* be called when finished or the connection
/// will return an error the next time it is used.
pub async fn copy_in_raw(
&mut self,
statement: &str,
) -> Result<PgCopyIn<PoolConnection<Postgres>>> {
pub async fn copy_in_raw(&self, statement: &str) -> Result<PgCopyIn<PoolConnection<Postgres>>> {
PgCopyIn::begin(self.acquire().await?, statement).await
}

Expand All @@ -101,10 +98,7 @@ impl Pool<Postgres> {
///
/// Command examples and accepted formats for `COPY` data are shown here:
/// https://www.postgresql.org/docs/current/sql-copy.html
pub async fn copy_out_raw(
&mut self,
statement: &str,
) -> Result<BoxStream<'static, Result<Bytes>>> {
pub async fn copy_out_raw(&self, statement: &str) -> Result<BoxStream<'static, Result<Bytes>>> {
pg_begin_copy_out(self.acquire().await?, statement).await
}
}
Expand Down
1 change: 1 addition & 0 deletions sqlx-core/src/postgres/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ mod migrate;
pub use arguments::{PgArgumentBuffer, PgArguments};
pub use column::PgColumn;
pub use connection::{PgConnection, PgConnectionInfo};
pub use copy::PgCopyIn;
pub use database::Postgres;
pub use error::{PgDatabaseError, PgErrorPosition};
pub use listener::{PgListener, PgNotification};
Expand Down