mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 14:34:19 +00:00
Add support for unsigned integers and binary in query! for mysql
This commit is contained in:
parent
d46acb0e0e
commit
f1b37b9bc2
3 changed files with 18 additions and 13 deletions
|
@ -1,11 +1,9 @@
|
|||
impl_database_ext! {
|
||||
sqlx::MySql {
|
||||
String,
|
||||
// TODO: Add after the new type refactor
|
||||
// u8,
|
||||
// u16,
|
||||
// u32,
|
||||
// u64,
|
||||
u8,
|
||||
u16,
|
||||
u32,
|
||||
u64,
|
||||
i8,
|
||||
i16,
|
||||
i32,
|
||||
|
@ -13,6 +11,12 @@ impl_database_ext! {
|
|||
f32,
|
||||
f64,
|
||||
|
||||
// CHAR, VAR_CHAR, TEXT
|
||||
String,
|
||||
|
||||
// BINARY, VAR_BINARY, BLOB
|
||||
Vec<u8>,
|
||||
|
||||
#[cfg(feature = "chrono")]
|
||||
sqlx::types::chrono::NaiveTime,
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@ impl_database_ext! {
|
|||
f32,
|
||||
f64,
|
||||
|
||||
// BYTEA
|
||||
Vec<u8>,
|
||||
|
||||
#[cfg(feature = "uuid")]
|
||||
sqlx::types::Uuid,
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ async fn connect() -> anyhow::Result<MySqlConnection> {
|
|||
macro_rules! test {
|
||||
($name:ident: $ty:ty: $($text:literal == $value:expr),+) => {
|
||||
#[cfg_attr(feature = "runtime-async-std", async_std::test)]
|
||||
#[cfg_attr(feature = "runtime-tokio", tokio::test)]
|
||||
#[cfg_attr(feature = "runtime-tokio", tokio::test)]
|
||||
async fn $name () -> anyhow::Result<()> {
|
||||
let mut conn = connect().await?;
|
||||
|
||||
|
@ -51,17 +51,15 @@ test!(mysql_string: String: "'helloworld'" == "helloworld");
|
|||
async fn mysql_bytes() -> anyhow::Result<()> {
|
||||
let mut conn = connect().await?;
|
||||
|
||||
let value = b"Hello, World";
|
||||
let value = &b"Hello, World"[..];
|
||||
|
||||
let row = sqlx::query("SELECT X'48656c6c6f2c20576f726c64' = ?, ?")
|
||||
.bind(&value[..])
|
||||
.bind(&value[..])
|
||||
let rec = sqlx::query!("SELECT (X'48656c6c6f2c20576f726c64' = ?) as _1, CAST(? as BINARY) as _2", value, value)
|
||||
.fetch_one(&mut conn)
|
||||
.await?;
|
||||
|
||||
assert!(row.get::<bool, _>(0));
|
||||
assert!(rec._1 != 0);
|
||||
|
||||
let output: Vec<u8> = row.get(1);
|
||||
let output: Vec<u8> = rec._2;
|
||||
|
||||
assert_eq!(&value[..], &*output);
|
||||
|
||||
|
|
Loading…
Reference in a new issue