From 3840d031c6e355df39400030fcf1a54ca7450141 Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Fri, 24 Jul 2020 08:07:07 -0700 Subject: [PATCH] test: add a test case for YEAR support (as u16) --- tests/mysql/mysql.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/mysql/mysql.rs b/tests/mysql/mysql.rs index f9bcf76c..7ab7b435 100644 --- a/tests/mysql/mysql.rs +++ b/tests/mysql/mysql.rs @@ -272,6 +272,30 @@ async fn it_can_bind_only_null_issue_540() -> anyhow::Result<()> { Ok(()) } +#[sqlx_macros::test] +async fn it_can_bind_and_return_years() -> anyhow::Result<()> { + let mut conn = new::().await?; + + conn.execute(r#" +CREATE TEMPORARY TABLE too_many_years ( + id INT PRIMARY KEY AUTO_INCREMENT, + the YEAR NOT NULL +); + "#).await?; + + sqlx::query(r#" +INSERT INTO too_many_years ( the ) VALUES ( ? ); + "#).bind(2142).execute(&mut conn).await?; + + let the: u16 = sqlx::query_scalar("SELECT the FROM too_many_years") + .fetch_one(&mut conn) + .await?; + + assert_eq!(the, 2142); + + Ok(()) +} + #[sqlx_macros::test] async fn it_can_prepare_then_execute() -> anyhow::Result<()> { let mut conn = new::().await?;