Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function fixMetadata(status: fb.Status, metadata?: fb.MessageMetadata): fb.MessageMetadata | undefined {
if (!metadata)
return undefined;
let ret: fb.MessageMetadata;
const outBuilder = metadata.getBuilderSync(status)!;
try {
for (let i = metadata.getCountSync(status) - 1; i >= 0; --i) {
switch (metadata.getTypeSync(status, i)) {
// Transforms CHAR descriptors to VARCHAR.
case sqlTypes.SQL_TEXT:
outBuilder.setTypeSync(status, i, sqlTypes.SQL_VARYING);
break;
// Transforms numeric descriptors to DOUBLE PRECISION.
case sqlTypes.SQL_SHORT:
case sqlTypes.SQL_LONG:
case sqlTypes.SQL_INT64:
case sqlTypes.SQL_FLOAT:
outBuilder.setTypeSync(status, i, sqlTypes.SQL_DOUBLE);
outBuilder.setLengthSync(status, i, 8);
outBuilder.setScaleSync(status, i, 0);
break;
}
}
ret = outBuilder.getMetadataSync(status)!;