[jOOQ/jOOQ#11641] MySQL and MariaDB SPLIT_PART

This commit is contained in:
Lukas Eder 2021-03-15 21:02:20 +01:00
parent 5acd6374e1
commit ed1167c84f
2 changed files with 15 additions and 1 deletions

View File

@ -299,6 +299,7 @@ final class Names {
static final Name N_STRREVERSE = unquotedName("strreverse");
static final Name N_SUBSTR = unquotedName("substr");
static final Name N_SUBSTRING = unquotedName("substring");
static final Name N_SUBSTRING_INDEX = unquotedName("substring_index");
static final Name N_SYSTEM_RANGE = unquotedName("system_range");
static final Name N_SYSTEM_TIME = unquotedName("system_time");
static final Name N_SYS_CONNECT_BY_PATH = unquotedName("sys_connect_by_path");

View File

@ -108,8 +108,21 @@ extends
case MARIADB:
case MYSQL: {
case MYSQL:
ctx.visit(DSL.substring(
function(N_SUBSTRING_INDEX, VARCHAR, string, delimiter, n),
case_((Field) n).when(one(), one()).else_(
DSL.length(function(N_SUBSTRING_INDEX, VARCHAR, string, delimiter, n.minus(one())))
.plus(DSL.length(delimiter))
.plus(one())
)
));
break;
case HSQLDB: {
Field<String> rS = DSL.field(name("s"), String.class);
Field<Integer> rN = DSL.field(name("n"), int.class);
Field<String> rD = DSL.field(name("d"), String.class);