mirror of
https://github.com/launchbadge/sqlx
synced 2024-09-20 22:31:56 +00:00
style: rustfmt
This commit is contained in:
parent
ae8800ccc4
commit
78fe88f51b
6 changed files with 22 additions and 11 deletions
|
@ -189,7 +189,9 @@ impl FromStr for CharSet {
|
|||
"utf8mb4" => CharSet::utf8mb4,
|
||||
|
||||
_ => {
|
||||
return Err(Error::Configuration(format!("unsupported MySQL charset: {}", char_set).into()));
|
||||
return Err(Error::Configuration(
|
||||
format!("unsupported MySQL charset: {}", char_set).into(),
|
||||
));
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -889,7 +891,9 @@ impl FromStr for Collation {
|
|||
"cp1250_polish_ci" => Collation::cp1250_polish_ci,
|
||||
|
||||
_ => {
|
||||
return Err(Error::Configuration(format!("unsupported MySQL collation: {}", collation).into()));
|
||||
return Err(Error::Configuration(
|
||||
format!("unsupported MySQL collation: {}", collation).into(),
|
||||
));
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -2,9 +2,7 @@ use bytes::Bytes;
|
|||
|
||||
use crate::common::StatementCache;
|
||||
use crate::error::Error;
|
||||
use crate::mysql::connection::{
|
||||
tls, MySqlStream, MAX_PACKET_SIZE,
|
||||
};
|
||||
use crate::mysql::connection::{tls, MySqlStream, MAX_PACKET_SIZE};
|
||||
use crate::mysql::protocol::connect::{
|
||||
AuthSwitchRequest, AuthSwitchResponse, Handshake, HandshakeResponse,
|
||||
};
|
||||
|
|
|
@ -4,10 +4,10 @@ use bytes::{Buf, Bytes};
|
|||
|
||||
use crate::error::Error;
|
||||
use crate::io::{BufStream, Decode, Encode};
|
||||
use crate::mysql::collation::{CharSet, Collation};
|
||||
use crate::mysql::io::MySqlBufExt;
|
||||
use crate::mysql::protocol::response::{EofPacket, ErrPacket, OkPacket, Status};
|
||||
use crate::mysql::protocol::{Capabilities, Packet};
|
||||
use crate::mysql::collation::{CharSet, Collation};
|
||||
use crate::mysql::{MySqlConnectOptions, MySqlDatabaseError};
|
||||
use crate::net::{MaybeTlsStream, Socket};
|
||||
|
||||
|
@ -35,7 +35,12 @@ pub(crate) enum Busy {
|
|||
impl MySqlStream {
|
||||
pub(super) async fn connect(options: &MySqlConnectOptions) -> Result<Self, Error> {
|
||||
let charset: CharSet = options.charset.parse()?;
|
||||
let collation: Collation = options.collation.as_deref().map(|collation| collation.parse()).transpose()?.unwrap_or_else(|| charset.default_collation());
|
||||
let collation: Collation = options
|
||||
.collation
|
||||
.as_deref()
|
||||
.map(|collation| collation.parse())
|
||||
.transpose()?
|
||||
.unwrap_or_else(|| charset.default_collation());
|
||||
|
||||
let socket = match options.socket {
|
||||
Some(ref path) => Socket::connect_uds(path).await?,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//! **MySQL** database driver.
|
||||
|
||||
mod arguments;
|
||||
mod collation;
|
||||
mod column;
|
||||
mod connection;
|
||||
mod database;
|
||||
|
@ -9,7 +10,6 @@ mod error;
|
|||
mod io;
|
||||
mod options;
|
||||
mod protocol;
|
||||
mod collation;
|
||||
mod row;
|
||||
mod transaction;
|
||||
mod type_info;
|
||||
|
|
|
@ -42,7 +42,11 @@ impl ConnectOptions for MySqlConnectOptions {
|
|||
let mut options = String::new();
|
||||
options.push_str(r#"SET sql_mode=(SELECT CONCAT(@@sql_mode, ',PIPES_AS_CONCAT,NO_ENGINE_SUBSTITUTION')),"#);
|
||||
options.push_str(r#"time_zone='+00:00',"#);
|
||||
options.push_str(&format!(r#"NAMES {} COLLATE {};"#, conn.stream.charset.as_str(), conn.stream.collation.as_str()));
|
||||
options.push_str(&format!(
|
||||
r#"NAMES {} COLLATE {};"#,
|
||||
conn.stream.charset.as_str(),
|
||||
conn.stream.collation.as_str()
|
||||
));
|
||||
|
||||
conn.execute(&*options).await?;
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ const COLLATE_UTF8MB4_UNICODE_CI: u16 = 224;
|
|||
impl Type<MySql> for str {
|
||||
fn type_info() -> MySqlTypeInfo {
|
||||
MySqlTypeInfo {
|
||||
r#type: ColumnType::VarString, // VARCHAR
|
||||
char_set: COLLATE_UTF8MB4_UNICODE_CI, // utf8mb4_unicode_ci
|
||||
r#type: ColumnType::VarString, // VARCHAR
|
||||
char_set: COLLATE_UTF8MB4_UNICODE_CI, // utf8mb4_unicode_ci
|
||||
flags: ColumnFlags::empty(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue