Skip to content

Commit

Permalink
fix new warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
abonander committed Jul 27, 2024
1 parent fc91f14 commit 02219cd
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
10 changes: 5 additions & 5 deletions sqlx-core/src/net/socket/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{cmp, io};

use crate::error::Error;

use crate::io::{Decode, Encode, AsyncRead, AsyncReadExt};
use crate::io::{AsyncRead, AsyncReadExt, Decode, Encode};

// Tokio, async-std, and std all use this as the default capacity for their buffered I/O.
const DEFAULT_BUF_SIZE: usize = 8192;
Expand Down Expand Up @@ -167,9 +167,9 @@ impl WriteBuffer {

self.sanity_check();
}

/// Read into the buffer from `source`, returning the number of bytes read.
///
///
/// The buffer is automatically advanced by the number of bytes read.
pub async fn read_from(&mut self, mut source: impl AsyncRead + Unpin) -> io::Result<usize> {
let read = match () {
Expand All @@ -179,11 +179,11 @@ impl WriteBuffer {
#[cfg(not(feature = "_rt-tokio"))]
_ => source.read(self.init_remaining_mut()).await?,
};

if read > 0 {
self.advance(read);
}

Ok(read)
}

Expand Down
9 changes: 5 additions & 4 deletions sqlx-postgres/src/copy.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use futures_core::future::BoxFuture;
use std::borrow::Cow;
use std::ops::{Deref, DerefMut};

use futures_core::future::BoxFuture;
use futures_core::stream::BoxStream;

use sqlx_core::bytes::{BufMut, Bytes};

use crate::connection::PgConnection;
use crate::error::{Error, Result};
use crate::ext::async_stream::TryAsyncStream;
use crate::io::{AsyncRead, AsyncReadExt};
use crate::io::AsyncRead;
use crate::message::{
CommandComplete, CopyData, CopyDone, CopyFail, CopyResponse, MessageFormat, Query,
};
Expand Down Expand Up @@ -45,7 +46,7 @@ impl PgConnection {
///
/// 1. by closing the connection, or:
/// 2. by using another connection to kill the server process that is sending the data as shown
/// [in this StackOverflow answer](https://stackoverflow.com/a/35319598).
/// [in this StackOverflow answer](https://stackoverflow.com/a/35319598).
///
/// If you don't read the stream to completion, the next time the connection is used it will
/// need to read and discard all the remaining queued data, which could take some time.
Expand Down Expand Up @@ -98,7 +99,7 @@ pub trait PgPoolCopyExt {
///
/// 1. by closing the connection, or:
/// 2. by using another connection to kill the server process that is sending the data as shown
/// [in this StackOverflow answer](https://stackoverflow.com/a/35319598).
/// [in this StackOverflow answer](https://stackoverflow.com/a/35319598).
///
/// If you don't read the stream to completion, the next time the connection is used it will
/// need to read and discard all the remaining queued data, which could take some time.
Expand Down
2 changes: 0 additions & 2 deletions sqlx-postgres/src/message/parse.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::i16;

use crate::io::PgBufMutExt;
use crate::io::{BufMutExt, Encode};
use crate::types::Oid;
Expand Down
4 changes: 2 additions & 2 deletions sqlx-sqlite/src/statement/virtual.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![allow(clippy::rc_buffer)]

use std::cmp;
use std::os::raw::c_char;
use std::ptr::{null, null_mut, NonNull};
use std::sync::Arc;
use std::{cmp, i32};

use libsqlite3_sys::{
sqlite3, sqlite3_prepare_v3, sqlite3_stmt, SQLITE_OK, SQLITE_PREPARE_PERSISTENT,
Expand Down Expand Up @@ -56,7 +56,7 @@ impl VirtualStatement {
pub(crate) fn new(mut query: &str, persistent: bool) -> Result<Self, Error> {
query = query.trim();

if query.len() > i32::max_value() as usize {
if query.len() > i32::MAX as usize {
return Err(err_protocol!(
"query string must be smaller than {} bytes",
i32::MAX
Expand Down
10 changes: 5 additions & 5 deletions sqlx-sqlite/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@
//! [Datatypes in SQLite: Type Affinity][type-affinity] (accessed 2023/11/20):
//!
//! > A column with NUMERIC affinity may contain values using all five storage classes.
//! When text data is inserted into a NUMERIC column, the storage class of the text is converted to
//! INTEGER or REAL (in order of preference) if the text is a well-formed integer or real literal,
//! respectively. If the TEXT value is a well-formed integer literal that is too large to fit in a
//! 64-bit signed integer, it is converted to REAL. For conversions between TEXT and REAL storage
//! classes, only the first 15 significant decimal digits of the number are preserved.
//! > When text data is inserted into a NUMERIC column, the storage class of the text is converted to
//! > INTEGER or REAL (in order of preference) if the text is a well-formed integer or real literal,
//! > respectively. If the TEXT value is a well-formed integer literal that is too large to fit in a
//! > 64-bit signed integer, it is converted to REAL. For conversions between TEXT and REAL storage
//! > classes, only the first 15 significant decimal digits of the number are preserved.
//!
//! With the SQLite3 interactive CLI, we can see that a higher-precision value
//! (20 digits in this case) is rounded off:
Expand Down

0 comments on commit 02219cd

Please sign in to comment.