[jOOQ/jOOQ#11641] Make sure generated switches have braces when needed

This commit is contained in:
Lukas Eder 2021-03-15 17:30:38 +01:00
parent 0e0cb694d4
commit 72b5751ca1
9 changed files with 17 additions and 5 deletions

View File

@ -93,10 +93,11 @@ extends
case SQLITE:
case SQLITE: {
// [#8275] Improved emulation for SQLite
ctx.sql('(').visit(value.cast(BIGINT)).sql(" + (").visit(value).sql(" > ").visit(value.cast(BIGINT)).sql("))");
break;
}

View File

@ -98,6 +98,7 @@ extends
default:
ctx.visit(function(N_EXP, getDataType(), value));
break;

View File

@ -88,10 +88,11 @@ extends
public final void accept(Context<?> ctx) {
switch (ctx.family()) {
case SQLITE:
case SQLITE: {
// [#8275] Improved emulation for SQLite
ctx.sql('(').visit(value.cast(BIGINT)).sql(" - (").visit(value).sql(" < ").visit(value.cast(BIGINT)).sql("))");
break;
}
default:
ctx.visit(function(N_FLOOR, getDataType(), value));

View File

@ -97,6 +97,7 @@ extends
case DERBY:
case SQLITE:
ctx.visit(DSL.exp(imul(DSL.ln(value), exponent)));

View File

@ -99,6 +99,9 @@ extends

View File

@ -100,13 +100,14 @@ extends
ctx.visit(DSL.rpad(string, imul(DSL.length(string), count), string));
break;
case SQLITE:
case SQLITE: {
// Emulation of REPEAT() for SQLite currently cannot be achieved
// using RPAD() above, as RPAD() expects characters, not strings
// Another option is documented here, though:
// https://stackoverflow.com/a/51792334/521799
ctx.visit(N_REPLACE).sql('(').visit(N_HEX).sql('(').visit(N_ZEROBLOB).sql('(').visit(count).sql(")), '00', ").visit(string).sql(')');
break;
}

View File

@ -94,10 +94,11 @@ extends
case FIREBIRD:
case SQLITE:
case SQLITE: {
// [#10135] Avoid REPEAT() emulation that is too complicated for SPACE(N)
ctx.visit(DSL.rpad(DSL.inline(' '), count));
break;
}

View File

@ -107,8 +107,9 @@ extends
case MARIADB:
case MYSQL:
case MYSQL: {
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);
@ -133,6 +134,7 @@ extends
withRecursive(s1, s2).select(DSL.coalesce(DSL.max(DSL.field(name("x"))), inline(""))).from(s2).where(s2.field("n").eq((Field) n))
);
break;
}
default:
ctx.visit(function(N_SPLIT_PART, getDataType(), string, delimiter, n));

View File

@ -102,6 +102,7 @@ extends
case SQLITE:
ctx.visit(DSL.power(value, inline(0.5)));
break;