Skip to content

Commit ebc604b

Browse files
author
Montana Low
committed
rustfmt
1 parent 45c93e3 commit ebc604b

File tree

4 files changed

+41
-19
lines changed

4 files changed

+41
-19
lines changed

sqlx-core/src/postgres/connection/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl PgConnection {
104104
}
105105

106106
pub async fn server_version(&mut self) -> Result<String, Error> {
107-
let result = self.fetch_one("SHOW server_version;",).await?;
107+
let result = self.fetch_one("SHOW server_version;").await?;
108108
let server_version: String = result.get("server_version");
109109

110110
Ok(server_version)

sqlx-core/src/postgres/copy.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ use crate::postgres::message::{
88
use crate::postgres::Postgres;
99
use bytes::{BufMut, Bytes};
1010
use futures_core::stream::BoxStream;
11+
use smallvec::alloc::borrow::Cow;
1112
use sqlx_rt::{AsyncRead, AsyncReadExt, AsyncWriteExt};
1213
use std::convert::TryFrom;
1314
use std::ops::{Deref, DerefMut};
14-
use smallvec::alloc::borrow::Cow;
1515

1616
impl PgConnection {
1717
/// Issue a `COPY FROM STDIN` statement and transition the connection to streaming data
@@ -238,13 +238,16 @@ impl<C: DerefMut<Target = PgConnection>> PgCopyIn<C> {
238238
)),
239239
Err(Error::Database(e)) => {
240240
match e.code() {
241-
Some(Cow::Borrowed("57014")) => { // postgres abort received error code
242-
conn.stream.recv_expect(MessageFormat::ReadyForQuery).await?;
241+
Some(Cow::Borrowed("57014")) => {
242+
// postgres abort received error code
243+
conn.stream
244+
.recv_expect(MessageFormat::ReadyForQuery)
245+
.await?;
243246
Ok(())
244-
},
245-
_ => Err(Error::Database(e))
247+
}
248+
_ => Err(Error::Database(e)),
246249
}
247-
},
250+
}
248251
Err(e) => Err(e),
249252
}
250253
}
@@ -264,7 +267,9 @@ impl<C: DerefMut<Target = PgConnection>> PgCopyIn<C> {
264267
.recv_expect(MessageFormat::CommandComplete)
265268
.await?;
266269

267-
conn.stream.recv_expect(MessageFormat::ReadyForQuery).await?;
270+
conn.stream
271+
.recv_expect(MessageFormat::ReadyForQuery)
272+
.await?;
268273

269274
Ok(cc.rows_affected())
270275
}

sqlx-core/src/postgres/message/copy.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::io::{BufExt, BufMutExt, Decode, Encode};
33
use bytes::{Buf, BufMut, Bytes};
44
use std::ops::Deref;
55

6-
76
/// The same structure is sent for both `CopyInResponse` and `CopyOutResponse`
87
pub struct CopyResponse {
98
pub format: i8,

tests/postgres/postgres.rs

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,13 +1069,20 @@ async fn it_supports_domain_types_in_composite_domain_types() -> anyhow::Result<
10691069
#[sqlx_macros::test]
10701070
async fn it_can_copy_in() -> anyhow::Result<()> {
10711071
let mut conn = new::<Postgres>().await?;
1072-
conn.execute(r#"
1072+
conn.execute(
1073+
r#"
10731074
CREATE TEMPORARY TABLE users (id INTEGER NOT NULL);
1074-
"#,).await?;
1075+
"#,
1076+
)
1077+
.await?;
10751078

1076-
let mut copy = conn.copy_in_raw(r#"
1079+
let mut copy = conn
1080+
.copy_in_raw(
1081+
r#"
10771082
COPY users (id) FROM STDIN WITH (FORMAT CSV, HEADER);
1078-
"#).await?;
1083+
"#,
1084+
)
1085+
.await?;
10791086

10801087
copy.send("id\n1\n2\n".as_bytes()).await?;
10811088
let rows = copy.finish().await?;
@@ -1095,13 +1102,20 @@ async fn it_can_copy_in() -> anyhow::Result<()> {
10951102
#[sqlx_macros::test]
10961103
async fn it_can_abort_copy_in() -> anyhow::Result<()> {
10971104
let mut conn = new::<Postgres>().await?;
1098-
conn.execute(r#"
1105+
conn.execute(
1106+
r#"
10991107
CREATE TEMPORARY TABLE users (id INTEGER NOT NULL);
1100-
"#,).await?;
1108+
"#,
1109+
)
1110+
.await?;
11011111

1102-
let mut copy = conn.copy_in_raw(r#"
1112+
let mut copy = conn
1113+
.copy_in_raw(
1114+
r#"
11031115
COPY users (id) FROM STDIN WITH (FORMAT CSV, HEADER);
1104-
"#).await?;
1116+
"#,
1117+
)
1118+
.await?;
11051119

11061120
copy.abort("this is only a test").await?;
11071121

@@ -1121,9 +1135,13 @@ async fn it_can_copy_out() -> anyhow::Result<()> {
11211135
let mut conn = new::<Postgres>().await?;
11221136

11231137
{
1124-
let mut copy = conn.copy_out_raw("
1138+
let mut copy = conn
1139+
.copy_out_raw(
1140+
"
11251141
COPY (SELECT generate_series(1, 2) AS id) TO STDOUT WITH (FORMAT CSV, HEADER);
1126-
").await?;
1142+
",
1143+
)
1144+
.await?;
11271145

11281146
assert_eq!(copy.next().await.unwrap().unwrap(), "id\n");
11291147
assert_eq!(copy.next().await.unwrap().unwrap(), "1\n");

0 commit comments

Comments
 (0)