[jOOQ/jOOQ#9131] Support parsing MySQL BIT(1) value literals

This commit is contained in:
Lukas Eder 2020-06-26 10:31:13 +02:00
parent 917796f484
commit 77a3943a65

View File

@ -6582,6 +6582,10 @@ final class ParserImpl implements Parser {
else if ((field = parseFieldBitwiseFunctionIf(ctx)) != null)
return field;
if (B.is(type))
if ((value = parseBitLiteralIf(ctx)) != null)
return DSL.inline((Boolean) value);
break;
case 'C':
@ -10725,6 +10729,23 @@ final class ParserImpl implements Parser {
return null;
}
private static final Boolean parseBitLiteralIf(ParserContext ctx) {
if (parseIf(ctx, "B'", false) || parseIf(ctx, "b'", false)) {
boolean result = false;
if (!parseIf(ctx, '0') && parseIf(ctx, '1'))
result = true;
if (parseIf(ctx, '0') || parseIf(ctx, '1'))
throw ctx.exception("Currently, only BIT(1) literals are supported");
parse(ctx, '\'');
return result;
}
return null;
}
private static final byte[] parseBinaryLiteralIf(ParserContext ctx) {
if (parseIf(ctx, "X'", false) || parseIf(ctx, "x'", false)) {
if (parseIf(ctx, '\''))