Skip to content

Commit d4c20bf

Browse files
committed
Fixed bug in the json and jsv writer introduced in the last commit in QueryService
1 parent 9c9763b commit d4c20bf

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

src/javaxt/express/services/QueryService.java

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -437,36 +437,48 @@ public void setCount(long count){
437437

438438
public void close(){
439439
isClosed = true;
440+
440441
if (format.equals("json")){
442+
if (x>0){
443+
str.append("]");
444+
441445

442-
str.append("]");
446+
if (addMetadata){
447+
if (metadata!=null){
448+
str.append(",\"metadata\":");
449+
str.append(metadata);
450+
}
451+
}
443452

444453

445-
if (addMetadata){
446-
if (metadata!=null){
447-
str.append(",\"metadata\":");
448-
str.append(metadata);
454+
if (count!=null){
455+
str.append(",\"total_rows\":");
456+
str.append(count);
449457
}
450-
}
451458

459+
if (this.elapsedTime!=null){
460+
double elapsedTime = (double)(this.elapsedTime)/1000d;
461+
BigDecimal time = new BigDecimal(elapsedTime).setScale(3, BigDecimal.ROUND_HALF_UP);
462+
str.append(",\"time\":");
463+
str.append(time);
464+
}
452465

453-
if (count!=null){
454-
str.append(",\"total_rows\":");
455-
str.append(count);
456-
}
466+
str.append("}");
457467

458-
if (this.elapsedTime!=null){
459-
double elapsedTime = (double)(this.elapsedTime)/1000d;
460-
BigDecimal time = new BigDecimal(elapsedTime).setScale(3, BigDecimal.ROUND_HALF_UP);
461-
str.append(",\"time\":");
462-
str.append(time);
463468
}
464-
465-
str.append("}");
469+
else{
470+
str.append("{}");
471+
}
466472
}
467473
else if (format.equals("jsv")){
468-
str.append("]}");
474+
if (x>0){
475+
str.append("]}");
476+
}
477+
else{
478+
str.append("{}");
479+
}
469480
}
481+
470482
}
471483

472484

0 commit comments

Comments
 (0)