Skip to content
Snippets Groups Projects
Unverified Commit 601113ff authored by Simon Belak's avatar Simon Belak Committed by GitHub
Browse files

MBQL: make `concat` work with any number of args (#12546)

MBQL (Redshift, Vertica, Oracle): make `concat` work with any number of args
parent ffd0b0ea
Branches
Tags
No related merge requests found
......@@ -142,6 +142,12 @@
(hsql/call :substr (sql.qp/->honeysql driver arg) (sql.qp/->honeysql driver start) (sql.qp/->honeysql driver length))
(hsql/call :substr (sql.qp/->honeysql driver arg) (sql.qp/->honeysql driver start))))
(defmethod sql.qp/->honeysql [:oracle :concat]
[driver [_ & args]]
(->> args
(map (partial sql.qp/->honeysql driver))
(reduce (partial hsql/call :concat))))
(defmethod sql.qp/->honeysql [:oracle :regex-match-first]
[driver [_ arg pattern]]
(hsql/call :regexp_substr (sql.qp/->honeysql driver arg) (sql.qp/->honeysql driver pattern)))
......
......@@ -139,6 +139,12 @@
(hsql/call :replace (sql.qp/->honeysql driver arg) (splice-raw-string-value driver pattern)
(splice-raw-string-value driver replacement)))
(defmethod sql.qp/->honeysql [:redshift :concat]
[driver [_ & args]]
(->> args
(map (partial sql.qp/->honeysql driver))
(reduce (partial hsql/call :concat))))
;;; +----------------------------------------------------------------------------------------------------------------+
;;; | metabase.driver.sql-jdbc impls |
;;; +----------------------------------------------------------------------------------------------------------------+
......
......@@ -100,6 +100,12 @@
one-day))
one-day))
(defmethod sql.qp/->honeysql [:vertica :concat]
[driver [_ & args]]
(->> args
(map (partial sql.qp/->honeysql driver))
(reduce (partial hsql/call :concat))))
(defmethod sql.qp/->honeysql [:vertica :regex-match-first]
[driver [_ arg pattern]]
(hsql/call :regexp_substr (sql.qp/->honeysql driver arg) (sql.qp/->honeysql driver pattern)))
......
......@@ -57,7 +57,9 @@
(deftest test-concat
(mt/test-drivers (mt/normal-drivers-with-feature :expressions)
(is (= "foobar" (test-string-extract [:concat "foo" "bar"])))))
(is (= "foobar" (test-string-extract [:concat "foo" "bar"])))
(testing "Does concat work with >2 args"
(is (= "foobar" (test-string-extract [:concat "f" "o" "o" "b" "a" "r"]))))))
(deftest test-regex-match-first
(mt/test-drivers (mt/normal-drivers-with-feature :expressions :regex)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment