Improve rendering of nulls in Spinner results.

This commit is contained in:
Greyson Parrelli
2023-05-08 19:47:42 -04:00
committed by Cody Henthorne
parent 970278228d
commit da27d74111
12 changed files with 19 additions and 18 deletions

View File

@@ -47,7 +47,7 @@
{{#each queryResult.rows}}
<tr>
{{#each this}}
<td><pre>{{{this}}}</pre></td>
<td><pre>{{#if (eq this null)}} <em class="null">null</em> {{else}} {{{this}}} {{/if}}</pre></td>
{{/each}}
</tr>
{{/each}}

View File

@@ -93,3 +93,6 @@ table.device-info, table.device-info tr, table.device-info td {
font-style: italic;
}
.null {
color: #666
}

View File

@@ -35,7 +35,7 @@
{{#each queryResult.rows}}
<tr>
{{#each this}}
<td><pre>{{{this}}}</pre></td>
<td><pre>{{#if (eq this null)}} <em class="null">null</em> {{else}} {{{this}}} {{/if}}</pre></td>
{{/each}}
</tr>
{{/each}}

View File

@@ -14,5 +14,5 @@ interface ColumnTransformer {
/**
* In certain circumstances (like some queries), the table name may not be guaranteed.
*/
fun transform(tableName: String?, columnName: String, cursor: Cursor): String
fun transform(tableName: String?, columnName: String, cursor: Cursor): String?
}

View File

@@ -8,13 +8,11 @@ object DefaultColumnTransformer : ColumnTransformer {
return true
}
override fun transform(tableName: String?, columnName: String, cursor: Cursor): String {
override fun transform(tableName: String?, columnName: String, cursor: Cursor): String? {
val index = cursor.getColumnIndex(columnName)
val data: String? = when (cursor.getType(index)) {
return when (cursor.getType(index)) {
Cursor.FIELD_TYPE_BLOB -> Base64.encodeToString(cursor.getBlob(index), 0)
else -> cursor.getString(index)
}
return data ?: "null"
}
}

View File

@@ -283,13 +283,13 @@ internal class SpinnerServer(
}
var timeOfFirstRowNanos = 0L
val rows = mutableListOf<List<String>>()
val rows = mutableListOf<List<String?>>()
while (moveToNext()) {
if (timeOfFirstRowNanos == 0L) {
timeOfFirstRowNanos = System.nanoTime()
}
val row = mutableListOf<String>()
val row = mutableListOf<String?>()
for (i in 0 until numColumns) {
val columnName: String = getColumnName(i)
try {
@@ -460,7 +460,7 @@ internal class SpinnerServer(
data class QueryResult(
val columns: List<String>,
val rows: List<List<String>>,
val rows: List<List<String?>>,
val rowCount: Int = rows.size,
val timeToFirstRow: String,
val timeToReadRows: String