From cc336366c9871cec519f1f45edeb651953b654a9 Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 23 Jun 2024 15:57:33 +1200 Subject: [PATCH] redis: show results in query tab --- db_redis.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/db_redis.go b/db_redis.go index a62c673..176d13c 100644 --- a/db_redis.go +++ b/db_redis.go @@ -180,8 +180,30 @@ func (ld *redisLoadedDatabase) ExecQuery(query string, resultArea *vcl.TListView return } - // Put ret into the data field somehow - fmt.Printf("result\n%#v\n", ret) + resultArea.SetEnabled(false) + resultArea.Clear() + + resultArea.Columns().Clear() + colVal := resultArea.Columns().Add() + colVal.SetCaption("Result") + + // The result is probably a single value or a string slice + switch ret := ret.(type) { + case []string: + // Multiple values + for _, single := range ret { + cell := resultArea.Items().Add() + cell.SetCaption(single) // formatUtf8 + } + + default: + // Single value + dataEntry := resultArea.Items().Add() + dataEntry.SetCaption(formatAny(ret)) // formatUtf8 + + } + + resultArea.SetEnabled(true) } func (ld *redisLoadedDatabase) Close() {