From f16f035c351b34acfe6558656398a922fd81457b Mon Sep 17 00:00:00 2001 From: Alex Skinner Date: Sun, 6 Dec 2026 01:18:05 +0000 Subject: [PATCH] Run the function tests that implicit-cast lookup (#418) now passes --- README.md | 6 +++--- src/functions.rs | 6 ++++-- tests/issue_fixes.rs | 3 +-- tests/mysql_functions.rs | 19 ++++--------------- tests/mysql_new_tests.rs | 12 +++++------- 5 files changed, 17 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 7797f26..e48e766 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,8 @@ Pinned to [KipData/KiteSQL](https://github.com/KipData/KiteSQL) `main` (`522eb00 | Cargo feature | MySQL behaviour | Upstream hook / issue | | --- | --- | --- | -| *(default)* | `SqlDialect::parse` with sqlparser MySQL + rewrite, `DataTypeMapper`, `comparison_type`, `boolean_text`, `begin_commits_active_transaction`, `SqlParser::with_set_autocommit`, prefix indexes, fixed-arity scalar functions via `Database::load` | [#404](https://github.com/KipData/KiteSQL/pull/404), [#406](https://github.com/KipData/KiteSQL/pull/406), [#407](https://github.com/KipData/KiteSQL/pull/407), [#409](https://github.com/KipData/KiteSQL/pull/409), [#410](https://github.com/KipData/KiteSQL/pull/410) | -| `hook-functions` | Variadic / `accepts_any_args` functions (`GREATEST`/`LEAST`, open-ended `CONCAT`, …) and richer binder lookup | Implicit-cast function lookup + `ScalarFunctionImpl::{accepts_arity,accepts_any_args,return_type_for}` ([#412](https://github.com/KipData/KiteSQL/issues/412)); FunctionRegistry/packs | +| *(default)* | `SqlDialect::parse` with sqlparser MySQL + rewrite, `DataTypeMapper`, `comparison_type`, `boolean_text`, `begin_commits_active_transaction`, `SqlParser::with_set_autocommit`, prefix indexes, fixed-arity scalar functions via `Database::load`, resolved by implicit cast | [#404](https://github.com/KipData/KiteSQL/pull/404), [#406](https://github.com/KipData/KiteSQL/pull/406), [#407](https://github.com/KipData/KiteSQL/pull/407), [#409](https://github.com/KipData/KiteSQL/pull/409), [#410](https://github.com/KipData/KiteSQL/pull/410), [#418](https://github.com/KipData/KiteSQL/pull/418) | +| `hook-functions` | Variadic / `accepts_any_args` functions (`GREATEST`/`LEAST`, open-ended `CONCAT`, …) and `return_type_for` | `ScalarFunctionImpl::{accepts_arity,accepts_any_args,return_type_for}`; implicit-cast lookup itself landed in [#418](https://github.com/KipData/KiteSQL/pull/418) ([#412](https://github.com/KipData/KiteSQL/issues/412)) | | `hook-collation` | `utf8mb4_0900_ai_ci` text comparison keys | Dialect collation hooks (`text_collation` / binary-collation detection) | | `hook-nulls-first` | NULLs first ascending / last descending | Dialect `nulls_first` hook | | `hook-numeric-typing` | Exact DECIMAL literals, `/` and `AVG` scale rules, arithmetic result types | Dialect `number_literal` / `arithmetic_return_type` / `avg_return_type` hooks | @@ -119,7 +119,7 @@ Text comparison follows MySQL 8's default collation: case- and accent-insensitiv ### MySQL Functions -Default build registers fixed-arity implementations through `Database::load` (for example `REPLACE`, `CONCAT` with 1..=8 arguments, `ROUND`, `UUID`, `ISNULL` over common types). Variadic/`accepts_any_args` forms and reliable use on length-bounded column types wait on `hook-functions` / [#412](https://github.com/KipData/KiteSQL/issues/412). +Default build registers fixed-arity implementations through `Database::load` (for example `REPLACE`, `CONCAT` with 1..=8 arguments, `ROUND`, `UUID`, `ISNULL` over common types). Arguments are resolved by implicit cast ([#418](https://github.com/KipData/KiteSQL/pull/418)), so length-bounded `VARCHAR(n)`, `DECIMAL(p,s)`, `VARBINARY(n)`, `TIME(n)` and `TIMESTAMP(n)` columns reach functions declared on the unbounded type, and NULL arguments resolve. Still open: variadic/`accepts_any_args` forms (`GREATEST`/`LEAST`, `CONCAT` over 8 arguments) wait on `hook-functions`, and numeric arguments to `VARCHAR` parameters (for example `CONCAT('a', 1)`, `LENGTH(int_col)`) are not an implicit cast in core. ### NULL Ordering (`hook-nulls-first`) diff --git a/src/functions.rs b/src/functions.rs index 0ecbf6f..a31a76e 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -73,8 +73,10 @@ impl MySqlFunctions { IntegerDivide::new(), ]; - // Upstream looks up functions by exact (name, arg_types); register HEX/ROUND - // overloads for the numeric types MySQL accepts. + // Upstream resolves arguments by implicit cast (KipData/KiteSQL#418), preferring the + // closest overload. HEX, ISNULL and ROUND keep one overload per type on purpose: their + // behaviour or result type follows the argument type (for example integers must not go + // through DOUBLE). for arg_type in ISNULL_ARG_TYPES { functions.push(Hex::new(arg_type.clone())); functions.push(IsNull::new(arg_type.clone())); diff --git a/tests/issue_fixes.rs b/tests/issue_fixes.rs index 5787ab0..6d7f22b 100644 --- a/tests/issue_fixes.rs +++ b/tests/issue_fixes.rs @@ -109,7 +109,7 @@ fn hex_boolean() -> Result<(), DatabaseError> { // Issue 4: Truly variadic (11+ arguments work) #[test] -#[ignore = "needs hook-functions variadic concat"] +#[ignore = "needs hook-functions: variadic CONCAT (#418 resolves fixed arity only)"] fn concat_variadic() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let db = database(&dir)?; @@ -157,7 +157,6 @@ fn locate_pos_less_than_1() -> Result<(), DatabaseError> { // Issue: NULL handling in ROUND #[test] -#[ignore = "upstream binder rejects NULL literal arg types"] fn round_null_handling() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let db = database(&dir)?; diff --git a/tests/mysql_functions.rs b/tests/mysql_functions.rs index fe3cce5..f008d5d 100644 --- a/tests/mysql_functions.rs +++ b/tests/mysql_functions.rs @@ -99,7 +99,6 @@ fn replace_semantics() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] fn replace_on_bounded_columns_in_dml() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let mut db = database(&dir)?; @@ -182,7 +181,6 @@ fn cms_link_backfill_statement() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] fn length_function() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let db = database(&dir)?; @@ -195,7 +193,6 @@ fn length_function() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] fn length_in_order_by_on_varchar_column() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let mut db = database(&dir)?; @@ -220,7 +217,6 @@ fn length_in_order_by_on_varchar_column() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] fn concat_functions() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let db = database(&dir)?; @@ -249,7 +245,6 @@ fn concat_functions() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] fn substring_index_function() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let db = database(&dir)?; @@ -278,7 +273,6 @@ fn substring_index_function() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] fn locate_instr_position_functions() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let db = database(&dir)?; @@ -314,7 +308,6 @@ fn locate_instr_position_functions() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] fn left_right_functions() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let db = database(&dir)?; @@ -341,7 +334,6 @@ fn lpad_rpad_functions() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] fn repeat_reverse_functions() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let db = database(&dir)?; @@ -356,7 +348,6 @@ fn repeat_reverse_functions() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] fn ltrim_rtrim_functions() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let db = database(&dir)?; @@ -392,7 +383,7 @@ fn uuid_function() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] +#[ignore = "needs hook-functions: variadic GREATEST/LEAST (#418 resolves fixed arity only)"] fn greatest_least_functions() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let db = database(&dir)?; @@ -454,7 +445,7 @@ fn round_function() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] +#[ignore = "needs hook-functions: variadic GREATEST/LEAST (#418 resolves fixed arity only)"] fn greatest_least_common_type() -> Result<(), DatabaseError> { use ordered_float::OrderedFloat; use rust_decimal::Decimal; @@ -514,7 +505,7 @@ fn greatest_least_common_type() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] +#[ignore = "needs hook-functions: variadic GREATEST/LEAST (#418 resolves fixed arity only)"] fn greatest_least_temporal_comparison() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let mut db = database(&dir)?; @@ -612,7 +603,6 @@ fn wrong_arity_is_an_error_not_a_panic() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] fn round_return_type_follows_argument() -> Result<(), DatabaseError> { use ordered_float::OrderedFloat; use rust_decimal::Decimal; @@ -651,7 +641,7 @@ fn round_return_type_follows_argument() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] +#[ignore = "needs hook-numeric-typing on upstream (exact DECIMAL literals)"] fn round_literal_is_exact() -> Result<(), DatabaseError> { use ordered_float::OrderedFloat; use rust_decimal::Decimal; @@ -711,7 +701,6 @@ fn locate_empty_needle_and_start_bounds() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] fn isnull_function() -> Result<(), DatabaseError> { let dir = TempDir::new().expect("temp dir"); let mut db = database(&dir)?; diff --git a/tests/mysql_new_tests.rs b/tests/mysql_new_tests.rs index 1695f98..5107f8e 100644 --- a/tests/mysql_new_tests.rs +++ b/tests/mysql_new_tests.rs @@ -78,7 +78,6 @@ fn locate_character_positions_not_bytes() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] fn round_with_decimal() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let mut db = database(&dir)?; @@ -170,7 +169,7 @@ fn hex_with_bigint_column() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] +#[ignore = "needs numeric -> VARCHAR argument casts, not an implicit cast in core (#418 follow-up)"] fn length_with_int_column() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let mut db = database(&dir)?; @@ -194,7 +193,7 @@ fn length_with_int_column() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] +#[ignore = "needs numeric -> VARCHAR argument casts, not an implicit cast in core (#418 follow-up)"] fn concat_with_numeric_arguments() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let db = database(&dir)?; @@ -223,7 +222,7 @@ fn concat_variadic_1_to_6_args() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] +#[ignore = "needs hook-functions: variadic GREATEST/LEAST (#418 resolves fixed arity only)"] fn greatest_least_with_integers() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let db = database(&dir)?; @@ -237,7 +236,7 @@ fn greatest_least_with_integers() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] +#[ignore = "needs hook-functions: variadic GREATEST/LEAST (#418 resolves fixed arity only)"] fn greatest_least_with_null() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let db = database(&dir)?; @@ -248,7 +247,7 @@ fn greatest_least_with_null() -> Result<(), DatabaseError> { } #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] +#[ignore = "needs hook-functions: variadic GREATEST/LEAST (#418 resolves fixed arity only)"] fn greatest_least_more_than_4_args() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let db = database(&dir)?; @@ -285,7 +284,6 @@ fn position_in_syntax_matches_mysql() -> Result<(), DatabaseError> { // String function edge cases from mysql-test func_str/lpad/rpad.test. #[test] -#[ignore = "needs hook-functions / exact-type binder workarounds"] fn string_function_edge_cases_match_mysql() -> Result<(), DatabaseError> { let dir = TempDir::new().unwrap(); let db = database(&dir)?;