mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-12-29 21:00:54 +00:00
fix(mysql): enum type derive and column overrides need to deref before eq
This commit is contained in:
parent
d209c60eb7
commit
6a251efb65
@ -135,7 +135,7 @@ fn expand_derive_has_sql_type_strong_enum(
|
||||
}
|
||||
|
||||
fn compatible(ty: &sqlx::mysql::MySqlTypeInfo) -> bool {
|
||||
ty == sqlx::mysql::MySqlTypeInfo::__enum()
|
||||
*ty == sqlx::mysql::MySqlTypeInfo::__enum()
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
@ -124,6 +124,14 @@ async fn test_column_override_nullable() -> anyhow::Result<()> {
|
||||
#[sqlx(transparent)]
|
||||
struct MyInt4(i32);
|
||||
|
||||
#[derive(PartialEq, Eq, Debug, sqlx::Type)]
|
||||
#[sqlx(rename_all = "lowercase")]
|
||||
enum MyEnum {
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
}
|
||||
|
||||
#[sqlx_macros::test]
|
||||
async fn test_column_override_wildcard() -> anyhow::Result<()> {
|
||||
struct Record {
|
||||
@ -154,4 +162,17 @@ async fn test_column_override_exact() -> anyhow::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[sqlx_macros::test]
|
||||
async fn test_column_override_exact_enum() -> anyhow::Result<()> {
|
||||
let mut conn = new::<MySql>().await?;
|
||||
|
||||
let record = sqlx::query!("select * from (select 'red' as `color: MyEnum`) records")
|
||||
.fetch_one(&mut conn)
|
||||
.await?;
|
||||
|
||||
assert_eq!(record.color, MyEnum::Red);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// we don't emit bind parameter typechecks for MySQL so testing the overrides is redundant
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user