Merge pull request #532 from LavaCoref/hotfix/lava/1_json

fix(dbsync): json column of zero length has no value, value parsing s…
This commit is contained in:
agapple
2018-03-12 16:37:50 +08:00
committed by GitHub

View File

@@ -969,17 +969,17 @@ public final class RowsLogBuffer {
default: default:
throw new IllegalArgumentException("!! Unknown JSON packlen = " + meta); throw new IllegalArgumentException("!! Unknown JSON packlen = " + meta);
} }
// len = buffer.getUint16(); if (0 == len) {
// buffer.forward(meta - 4); // fixed issue #1 by lava, json column of zero length has no value, value parsing should be skipped
value = "";
} else {
int position = buffer.position(); int position = buffer.position();
Json_Value jsonValue = JsonConversion.parse_value(buffer.getUint8(), buffer, len - 1, charsetName); Json_Value jsonValue = JsonConversion.parse_value(buffer.getUint8(), buffer, len - 1, charsetName);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
jsonValue.toJsonString(builder, charsetName); jsonValue.toJsonString(builder, charsetName);
value = builder.toString(); value = builder.toString();
buffer.position(position + len); buffer.position(position + len);
// byte[] binary = new byte[len]; }
// buffer.fillBytes(binary, 0, len);
// value = binary;
javaType = Types.VARCHAR; javaType = Types.VARCHAR;
length = len; length = len;
break; break;