From 99c36465d02f770e5b0578fa36b3a821f5372d4c Mon Sep 17 00:00:00 2001 From: metamben <103100869+metamben@users.noreply.github.com> Date: Tue, 2 May 2023 20:29:44 +0300 Subject: [PATCH] Take an optional length instead of end for :substring (#30462) Fixes #29948. --- src/metabase/lib/schema/expression/string.cljc | 8 ++++---- test/metabase/query_processor_test/test_mlv2.clj | 4 ---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/metabase/lib/schema/expression/string.cljc b/src/metabase/lib/schema/expression/string.cljc index 60bfb300d4e..01d18491801 100644 --- a/src/metabase/lib/schema/expression/string.cljc +++ b/src/metabase/lib/schema/expression/string.cljc @@ -20,10 +20,10 @@ #_find [:schema [:ref ::expression/string]] #_replace [:schema [:ref ::expression/string]]) -(mbql-clause/define-tuple-mbql-clause :substring :- :type/Text - #_str [:schema [:ref ::expression/string]] - #_start [:schema [:ref ::expression/integer]] - #_end [:schema [:ref ::expression/integer]]) +(mbql-clause/define-catn-mbql-clause :substring :- :type/Text + [:str [:schema [:ref ::expression/string]]] + [:start [:schema [:ref ::expression/integer]]] + [:length [:? [:schema [:ref ::expression/integer]]]]) (mbql-clause/define-catn-mbql-clause :concat :- :type/Text [:args [:repeat {:min 2} [:schema [:ref ::expression/string]]]]) diff --git a/test/metabase/query_processor_test/test_mlv2.clj b/test/metabase/query_processor_test/test_mlv2.clj index b91197c9237..392168366c8 100644 --- a/test/metabase/query_processor_test/test_mlv2.clj +++ b/test/metabase/query_processor_test/test_mlv2.clj @@ -63,10 +63,6 @@ (mbql.u/match-one &match :field "#29946"))) - ;; #29948: `:substring` is broken - (mbql.u/match-one legacy-query - :substring - "#29948") ;; #29949: missing schema (mbql.u/match-one legacy-query :regex-match-first -- GitLab