Skip to content
Snippets Groups Projects
user avatar
john-metabase authored
* Improves consistency of substring in MBQL

Standard SQL SUBSTRING() uses a 1-based start index, with various drivers
handling a 0 start index in different ways. To make the behavior of substring
consistent across drivers, we will always convert a 0 start index in MBQL
to a 1 in SQL. The ->honeysql implementation of substring has been generalized
and drivers can now override just the name of the substring function, or the
entire expression if necessary. SQL Server now calls the parent implementation.

Resolves #12445

* Fixes substring from 0 in Mongo

* Adds arg to substring parent call

* Fix docs and helper text for substring()

* Adds schema to require positive integer index for substring

* WIP, adds frontend validation for substring index arg

* Adds frontend test for substring arg validation

* Updates substring test to expect exception on index 0

* Update src/metabase/driver/sql/query_processor.clj

Co-authored-by: default avatarmetamben <103100869+metamben@users.noreply.github.com>

* Use s/if instead of s/conditional

* Fix substring call in mysql substring spec

* Reverts driver and sql.qp changes for substring index

* Reverts changes to dispatch-by-clause-name-or-class

* Fixes typeinferencer test substring index

* Adds test for canonicalizing substring

* Fixes substring canonicalization with extra args

* Updates string extracts test to account for substring canonicalization

* Rewrites resolver validation application

* Adds test case for frontend expression validation errors

* Fixes frontend compiler spec for new substring validation

---------

Co-authored-by: default avatarmetamben <103100869+metamben@users.noreply.github.com>
a39b710e
History
Name Last commit Last update