mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-02 15:25:32 +00:00
Run rustfmt
This commit is contained in:
parent
f67872cbcf
commit
5e719917c0
@ -1,12 +1,12 @@
|
|||||||
use chrono::{NaiveDateTime, NaiveDate, Timelike, Datelike};
|
|
||||||
use byteorder::{ByteOrder, LittleEndian};
|
use byteorder::{ByteOrder, LittleEndian};
|
||||||
|
use chrono::{Datelike, NaiveDate, NaiveDateTime, Timelike};
|
||||||
|
|
||||||
use crate::decode::{Decode, DecodeError};
|
use crate::decode::{Decode, DecodeError};
|
||||||
use crate::encode::Encode;
|
use crate::encode::Encode;
|
||||||
|
use crate::mysql::protocol::Type;
|
||||||
|
use crate::mysql::types::MySqlTypeMetadata;
|
||||||
use crate::mysql::MySql;
|
use crate::mysql::MySql;
|
||||||
use crate::types::HasSqlType;
|
use crate::types::HasSqlType;
|
||||||
use crate::mysql::types::{MySqlTypeMetadata};
|
|
||||||
use crate::mysql::protocol::Type;
|
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
|
||||||
impl HasSqlType<NaiveDateTime> for MySql {
|
impl HasSqlType<NaiveDateTime> for MySql {
|
||||||
@ -68,7 +68,7 @@ impl Decode<MySql> for NaiveDateTime {
|
|||||||
LittleEndian::read_u32(&raw[8..])
|
LittleEndian::read_u32(&raw[8..])
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
date.and_hms(0, 0, 0)
|
date.and_hms(0, 0, 0)
|
||||||
@ -117,7 +117,7 @@ fn decode_date(raw: &[u8]) -> NaiveDate {
|
|||||||
NaiveDate::from_ymd(
|
NaiveDate::from_ymd(
|
||||||
LittleEndian::read_u16(raw) as i32,
|
LittleEndian::read_u16(raw) as i32,
|
||||||
raw[2] as u32,
|
raw[2] as u32,
|
||||||
raw[3] as u32
|
raw[3] as u32,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ use byteorder::LittleEndian;
|
|||||||
|
|
||||||
use crate::decode::{Decode, DecodeError};
|
use crate::decode::{Decode, DecodeError};
|
||||||
use crate::encode::Encode;
|
use crate::encode::Encode;
|
||||||
use crate::mysql::io::{BufMutExt};
|
use crate::mysql::io::BufMutExt;
|
||||||
use crate::mysql::protocol::Type;
|
use crate::mysql::protocol::Type;
|
||||||
use crate::mysql::types::MySqlTypeMetadata;
|
use crate::mysql::types::MySqlTypeMetadata;
|
||||||
use crate::mysql::MySql;
|
use crate::mysql::MySql;
|
||||||
|
@ -48,14 +48,15 @@ where
|
|||||||
options,
|
options,
|
||||||
});
|
});
|
||||||
|
|
||||||
for _ in 0.. pool.options.min_size {
|
for _ in 0..pool.options.min_size {
|
||||||
let raw = pool.new_conn(
|
let raw = pool
|
||||||
Instant::now() + pool.options.connect_timeout
|
.new_conn(Instant::now() + pool.options.connect_timeout)
|
||||||
).await?;
|
.await?;
|
||||||
|
|
||||||
pool_tx.send(Idle {
|
pool_tx
|
||||||
|
.send(Idle {
|
||||||
raw,
|
raw,
|
||||||
since: Instant::now()
|
since: Instant::now(),
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
@ -102,10 +102,12 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<DB> Default for Builder<DB>
|
impl<DB> Default for Builder<DB>
|
||||||
where
|
where
|
||||||
DB: Database
|
DB: Database,
|
||||||
{
|
{
|
||||||
fn default() -> Self { Self::new() }
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct Options {
|
pub(crate) struct Options {
|
||||||
|
@ -3,8 +3,8 @@ use futures_util::{future, TryStreamExt};
|
|||||||
|
|
||||||
use crate::arguments::Arguments;
|
use crate::arguments::Arguments;
|
||||||
use crate::{
|
use crate::{
|
||||||
arguments::IntoArguments, database::Database, encode::Encode,
|
arguments::IntoArguments, database::Database, encode::Encode, executor::Executor, row::FromRow,
|
||||||
executor::Executor, row::FromRow, types::HasSqlType,
|
types::HasSqlType,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// SQL query with bind parameters, which maps rows to an explicit output type.
|
/// SQL query with bind parameters, which maps rows to an explicit output type.
|
||||||
|
@ -71,13 +71,13 @@ async fn query_by_string() -> sqlx::Result<()> {
|
|||||||
let string = "Hello, world!".to_string();
|
let string = "Hello, world!".to_string();
|
||||||
|
|
||||||
let result = sqlx::query!(
|
let result = sqlx::query!(
|
||||||
"SELECT * from (VALUES('Hello, world!')) strings(string)\
|
"SELECT * from (VALUES('Hello, world!')) strings(string)\
|
||||||
where string = $1 or string = $2",
|
where string = $1 or string = $2",
|
||||||
string,
|
string,
|
||||||
string[..]
|
string[..]
|
||||||
)
|
)
|
||||||
.fetch_one(&mut conn)
|
.fetch_one(&mut conn)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
assert_eq!(result.string, string);
|
assert_eq!(result.string, string);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user