Skip to content

Commit 7588012

Browse files
committed
Add jsql support for reading boolean value
1 parent 2946a25 commit 7588012

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/main/java/picoded/dstack/jsql/JSql_DataObjectMapUtil.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,36 @@ protected static Object extractNonArrayValueFromPos(JSqlResult r, int pos) {
259259
} else if (baseType == Core_DataType.TEXT.getValue()) { // Text
260260
return r.get("tVl").getString(pos);
261261
}
262-
262+
263+
//
264+
// Boolean value support
265+
//
266+
if(baseType == Core_DataType.BOOLEAN.getValue()){
267+
String tVl = r.getString("tVl");
268+
if(tVl.equalsIgnoreCase("true")){
269+
return true;
270+
}
271+
if(tVl.equalsIgnoreCase("false")){
272+
return false;
273+
}
274+
// get the value from nVl
275+
int nVl = r.getInt("nVl");
276+
if(nVl == 1){
277+
return true;
278+
}
279+
if(nVl == 0){
280+
return false;
281+
}
282+
throw new JSqlException("Invalid boolean value: tVl=" + tVl + ", nVl=" + nVl);
283+
}
284+
263285
//
264286
// Binary value
265287
//
266288
if (baseType == Core_DataType.BINARY.getValue()) {
267289
// Older base64 stroage format
268290
// return (Base64.getDecoder().decode((String) (r.get("tVl").get(pos))));
269-
291+
270292
Object rawValue = r.get("rVl").get(pos);
271293
if (rawValue instanceof java.sql.Blob) {
272294
java.sql.Blob blobData = (java.sql.Blob) rawValue;

0 commit comments

Comments
 (0)