Skip to content

Commit a4298c4

Browse files
authored
Fix printing of variables with empty values and rows with no columns (#853)
## Usage and product changes Enhance printing logic to handle two special cases of received answers: * When a variable with no values is returned, an empty result will be shown instead of a crash (it used to be considered an impossible situation). * When concept rows are returned, but they do not have any columns inside (possible for delete stages), a special message is written for every row processed (this behavior is temporarily different from Console).
1 parent c48670f commit a4298c4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

framework/output/LogOutput.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import com.typedb.driver.api.concept.instance.Instance
2525
import com.typedb.driver.api.concept.instance.Relation
2626
import com.typedb.driver.api.concept.type.Type
2727
import com.typedb.driver.api.concept.value.Value
28+
import com.typedb.driver.common.exception.TypeDBDriverException
2829
import com.typedb.studio.framework.common.Util
2930
import com.typedb.studio.framework.common.theme.Color
3031
import com.typedb.studio.framework.common.theme.Theme
@@ -249,16 +250,23 @@ internal class LogOutput constructor(
249250
val content = columnNames
250251
.stream()
251252
.map { columnName: String ->
252-
val concept = conceptRow[columnName]
253253
val sb = StringBuilder("$")
254254
sb.append(columnName)
255255
sb.append(" ".repeat(columnsWidth - columnName.length + 1))
256256
sb.append("| ")
257-
sb.append(conceptDisplayString(if (concept.isValue) concept.asValue() else concept))
257+
try {
258+
val concept = conceptRow[columnName]
259+
sb.append(conceptDisplayString(if (concept.isValue) concept.asValue() else concept))
260+
} catch (_: TypeDBDriverException) {
261+
// TODO: substitute the "try catch" by an optional processing when implemented
262+
}
258263
sb.toString()
259264
}.collect(Collectors.joining("\n"))
260265

261266
val sb = StringBuilder(indent(CONTENT_INDENT, content))
267+
if (content.isEmpty()) {
268+
sb.append("Row does not have columns to show")
269+
}
262270
sb.append("\n")
263271
sb.append(lineDashSeparator(columnsWidth))
264272
return sb.toString()

0 commit comments

Comments
 (0)