From 7becff70ba21ab314b2e613671165fcdb25b9aec Mon Sep 17 00:00:00 2001 From: Arthur Date: Thu, 7 Dec 2023 14:35:01 +0800 Subject: [PATCH 1/7] fix duplicate "`" in FromRow "default" attribute doc comment --- sqlx-core/src/from_row.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlx-core/src/from_row.rs b/sqlx-core/src/from_row.rs index 234dd94176..a6129b9611 100644 --- a/sqlx-core/src/from_row.rs +++ b/sqlx-core/src/from_row.rs @@ -91,7 +91,7 @@ use crate::{error::Error, row::Row}; /// will set the value of the field `location` to the default value of `Option`, /// which is `None`. /// -/// Moreover, if the struct has an implementation for [`Default`], you can use the `default`` +/// Moreover, if the struct has an implementation for [`Default`], you can use the `default` /// attribute at the struct level rather than for each single field. If a field does not appear in the result, /// its value is taken from the `Default` implementation for the struct. /// For example: From 91c6e6668b824604cd8ea3c5e915d3882c5261be Mon Sep 17 00:00:00 2001 From: Jesse Wang Date: Tue, 12 Dec 2023 22:53:00 +1300 Subject: [PATCH 2/7] fix(postgres): avoid unnecessary flush in PgCopyIn::read_from --- sqlx-postgres/src/copy.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sqlx-postgres/src/copy.rs b/sqlx-postgres/src/copy.rs index f5a6ea8573..c6daea7774 100644 --- a/sqlx-postgres/src/copy.rs +++ b/sqlx-postgres/src/copy.rs @@ -221,10 +221,6 @@ impl> PgCopyIn { } let conn: &mut PgConnection = self.conn.as_deref_mut().expect("copy_from: conn taken"); - - // flush any existing messages in the buffer and clear it - conn.stream.flush().await?; - loop { let buf = conn.stream.write_buffer_mut(); From 9c45eaa062217ed44f8d4129e9ae4022b9a5e713 Mon Sep 17 00:00:00 2001 From: Tadgh Henry <47073445+tadghh@users.noreply.github.com> Date: Tue, 2 Jan 2024 12:49:53 -0600 Subject: [PATCH 3/7] Fixed badge styling whitespace is being interpreted by the a tag causing blue hyperlinks to show up between the badges. --- README.md | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 14d965837d..6afef1b138 100644 --- a/README.md +++ b/README.md @@ -10,27 +10,20 @@
- actions status - + actions status Crates.io version - + alt="Crates.io version" /> - chat - + chat - docs.rs docs - + docs.rs docs - Download + Download
From 9b0a09387c399aacccd4a00c0cccaf861b825a07 Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Fri, 5 Jan 2024 18:51:27 -0800 Subject: [PATCH 4/7] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6afef1b138..e713c96690 100644 --- a/README.md +++ b/README.md @@ -75,8 +75,8 @@ SQLx is an async, pure Rust SQL crate featuring compile-time check † The SQLite driver uses the libsqlite3 C library as SQLite is an embedded database (the only way we could be pure Rust for SQLite is by porting _all_ of SQLite to Rust). -†† SQLx uses `#![forbid(unsafe_code)]` unless the `sqlite` feature is enabled. As the SQLite driver interacts -with C, those interactions are `unsafe`. +†† SQLx uses `#![forbid(unsafe_code)]` unless the `sqlite` feature is enabled. +The SQLite driver directly invokes the SQLite3 API via `libsqlite3-sys`, which requires `unsafe`. From 4c229946055765040414f0c0f3395fb882244a13 Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Fri, 5 Jan 2024 18:55:34 -0800 Subject: [PATCH 5/7] fix(core): export `net::socket::WriteBuffer` --- sqlx-core/src/net/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sqlx-core/src/net/mod.rs b/sqlx-core/src/net/mod.rs index 3c75f32c92..f9c43668ab 100644 --- a/sqlx-core/src/net/mod.rs +++ b/sqlx-core/src/net/mod.rs @@ -1,4 +1,6 @@ mod socket; pub mod tls; -pub use socket::{connect_tcp, connect_uds, BufferedSocket, Socket, SocketIntoBox, WithSocket}; +pub use socket::{ + connect_tcp, connect_uds, BufferedSocket, Socket, SocketIntoBox, WithSocket, WriteBuffer, +}; From 7044a928586a37bd9989c0e895b2d9a2a9a8a8a0 Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Fri, 5 Jan 2024 19:05:16 -0800 Subject: [PATCH 6/7] fix: fix new warnings that cropped up --- sqlx-core/src/net/socket/mod.rs | 4 +++- sqlx-postgres/src/message/mod.rs | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/sqlx-core/src/net/socket/mod.rs b/sqlx-core/src/net/socket/mod.rs index f11c10dedd..076aa9a3e3 100644 --- a/sqlx-core/src/net/socket/mod.rs +++ b/sqlx-core/src/net/socket/mod.rs @@ -244,6 +244,8 @@ pub async fn connect_uds, Ws: WithSocket>( ) -> crate::Result { #[cfg(not(unix))] { + drop((path, with_socket)); + return Err(io::Error::new( io::ErrorKind::Unsupported, "Unix domain sockets are not supported on this platform", @@ -270,7 +272,7 @@ pub async fn connect_uds, Ws: WithSocket>( return Ok(with_socket.with_socket(stream)); } - #[cfg(not(feature = "_rt-async-std"))] + #[cfg(all(unix, not(feature = "_rt-async-std")))] { crate::rt::missing_rt((path, with_socket)) } diff --git a/sqlx-postgres/src/message/mod.rs b/sqlx-postgres/src/message/mod.rs index 6e7daad239..ef1dbfabf0 100644 --- a/sqlx-postgres/src/message/mod.rs +++ b/sqlx-postgres/src/message/mod.rs @@ -37,6 +37,7 @@ pub use copy::{CopyData, CopyDone, CopyFail, CopyResponse}; pub use data_row::DataRow; pub use describe::Describe; pub use execute::Execute; +#[allow(unused_imports)] pub use flush::Flush; pub use notification::Notification; pub use parameter_description::ParameterDescription; From b5592b0642b0ecd1d7e0c8e2be97af834461953e Mon Sep 17 00:00:00 2001 From: benluelo Date: Wed, 1 Feb 2023 00:01:39 -0500 Subject: [PATCH 7/7] fix: Decode and Encode derives (#1031) --- sqlx-macros-core/src/derives/decode.rs | 27 ++++++++++++-------------- sqlx-macros-core/src/derives/encode.rs | 27 ++++++++++++-------------- 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/sqlx-macros-core/src/derives/decode.rs b/sqlx-macros-core/src/derives/decode.rs index f926718f6c..b848c69a19 100644 --- a/sqlx-macros-core/src/derives/decode.rs +++ b/sqlx-macros-core/src/derives/decode.rs @@ -9,7 +9,7 @@ use syn::punctuated::Punctuated; use syn::token::Comma; use syn::{ parse_quote, Arm, Data, DataEnum, DataStruct, DeriveInput, Field, Fields, FieldsNamed, - FieldsUnnamed, Stmt, Variant, + FieldsUnnamed, Stmt, TypeParamBound, Variant, }; pub fn expand_derive_decode(input: &DeriveInput) -> syn::Result { @@ -265,24 +265,21 @@ fn expand_derive_decode_struct( if cfg!(feature = "postgres") { let ident = &input.ident; - // extract type generics - let generics = &input.generics; - let (_, ty_generics, _) = generics.split_for_impl(); + let (_, ty_generics, where_clause) = input.generics.split_for_impl(); - // add db type for impl generics & where clause - let mut generics = generics.clone(); - generics.params.insert(0, parse_quote!('r)); - - let predicates = &mut generics.make_where_clause().predicates; - - for field in fields { - let ty = &field.ty; + let mut generics = input.generics.clone(); - predicates.push(parse_quote!(#ty: ::sqlx::decode::Decode<'r, ::sqlx::Postgres>)); - predicates.push(parse_quote!(#ty: ::sqlx::types::Type<::sqlx::Postgres>)); + // add db type for impl generics & where clause + for type_param in &mut generics.type_params_mut() { + type_param.bounds.extend::<[TypeParamBound; 2]>([ + parse_quote!(for<'decode> ::sqlx::decode::Decode<'decode, ::sqlx::Postgres>), + parse_quote!(::sqlx::types::Type<::sqlx::Postgres>), + ]); } - let (impl_generics, _, where_clause) = generics.split_for_impl(); + generics.params.push(parse_quote!('r)); + + let (impl_generics, _, _) = generics.split_for_impl(); let reads = fields.iter().map(|field| -> Stmt { let id = &field.ident; diff --git a/sqlx-macros-core/src/derives/encode.rs b/sqlx-macros-core/src/derives/encode.rs index 7bb568210f..a70bb079d9 100644 --- a/sqlx-macros-core/src/derives/encode.rs +++ b/sqlx-macros-core/src/derives/encode.rs @@ -9,7 +9,7 @@ use syn::punctuated::Punctuated; use syn::token::Comma; use syn::{ parse_quote, Data, DataEnum, DataStruct, DeriveInput, Expr, Field, Fields, FieldsNamed, - FieldsUnnamed, Lifetime, LifetimeDef, Stmt, Variant, + FieldsUnnamed, Lifetime, LifetimeDef, Stmt, TypeParamBound, Variant, }; pub fn expand_derive_encode(input: &DeriveInput) -> syn::Result { @@ -205,24 +205,21 @@ fn expand_derive_encode_struct( let ident = &input.ident; let column_count = fields.len(); - // extract type generics - let generics = &input.generics; - let (_, ty_generics, _) = generics.split_for_impl(); + let (_, ty_generics, where_clause) = input.generics.split_for_impl(); - // add db type for impl generics & where clause - let mut generics = generics.clone(); - - let predicates = &mut generics.make_where_clause().predicates; - - for field in fields { - let ty = &field.ty; + let mut generics = input.generics.clone(); - predicates - .push(parse_quote!(#ty: for<'q> ::sqlx::encode::Encode<'q, ::sqlx::Postgres>)); - predicates.push(parse_quote!(#ty: ::sqlx::types::Type<::sqlx::Postgres>)); + // add db type for impl generics & where clause + for type_param in &mut generics.type_params_mut() { + type_param.bounds.extend::<[TypeParamBound; 2]>([ + parse_quote!(for<'encode> ::sqlx::encode::Encode<'encode, ::sqlx::Postgres>), + parse_quote!(::sqlx::types::Type<::sqlx::Postgres>), + ]); } - let (impl_generics, _, where_clause) = generics.split_for_impl(); + generics.params.push(parse_quote!('q)); + + let (impl_generics, _, _) = generics.split_for_impl(); let writes = fields.iter().map(|field| -> Stmt { let id = &field.ident;