Skip to content

Commit a304161

Browse files
Copy API improvement (#1536) (#1537)
* expose PgCopyIn * downgrade Pool<Posgres> copy_in_raw/out_row to take &self
1 parent c8db803 commit a304161

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

sqlx-core/src/postgres/copy.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ impl Pool<Postgres> {
7575
/// ### Note
7676
/// [PgCopyIn::finish] or [PgCopyIn::abort] *must* be called when finished or the connection
7777
/// will return an error the next time it is used.
78-
pub async fn copy_in_raw(
79-
&mut self,
80-
statement: &str,
81-
) -> Result<PgCopyIn<PoolConnection<Postgres>>> {
78+
pub async fn copy_in_raw(&self, statement: &str) -> Result<PgCopyIn<PoolConnection<Postgres>>> {
8279
PgCopyIn::begin(self.acquire().await?, statement).await
8380
}
8481

@@ -101,10 +98,7 @@ impl Pool<Postgres> {
10198
///
10299
/// Command examples and accepted formats for `COPY` data are shown here:
103100
/// https://www.postgresql.org/docs/current/sql-copy.html
104-
pub async fn copy_out_raw(
105-
&mut self,
106-
statement: &str,
107-
) -> Result<BoxStream<'static, Result<Bytes>>> {
101+
pub async fn copy_out_raw(&self, statement: &str) -> Result<BoxStream<'static, Result<Bytes>>> {
108102
pg_begin_copy_out(self.acquire().await?, statement).await
109103
}
110104
}

sqlx-core/src/postgres/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ mod migrate;
2626
pub use arguments::{PgArgumentBuffer, PgArguments};
2727
pub use column::PgColumn;
2828
pub use connection::{PgConnection, PgConnectionInfo};
29+
pub use copy::PgCopyIn;
2930
pub use database::Postgres;
3031
pub use error::{PgDatabaseError, PgErrorPosition};
3132
pub use listener::{PgListener, PgNotification};

0 commit comments

Comments
 (0)