Merge pull request #914 from trheyi/main

fix: Update processRead to return string representation of table data
This commit is contained in:
Max 2025-03-31 09:19:27 +08:00 committed by GitHub
commit d3cc034e07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 8 deletions

View file

@ -9,7 +9,6 @@ import (
"time" "time"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/yaoapp/gou/application"
"github.com/yaoapp/gou/fs" "github.com/yaoapp/gou/fs"
"github.com/yaoapp/gou/model" "github.com/yaoapp/gou/model"
gouProcess "github.com/yaoapp/gou/process" gouProcess "github.com/yaoapp/gou/process"
@ -370,12 +369,7 @@ func processUnload(process *gouProcess.Process) interface{} {
func processRead(process *gouProcess.Process) interface{} { func processRead(process *gouProcess.Process) interface{} {
process.ValidateArgNums(1) process.ValidateArgNums(1)
tab := MustGet(process) // 0 tab := MustGet(process) // 0
source := map[string]interface{}{} return string(tab.Read())
err := application.Parse(tab.file, tab.Read(), &source)
if err != nil {
exception.New(err.Error(), 500).Throw()
}
return source
} }
// processExists yao.table.Exists table_name // processExists yao.table.Exists table_name

View file

@ -637,7 +637,7 @@ func TestProcessRead(t *testing.T) {
res := process.New("yao.table.Read", "pet").Run() res := process.New("yao.table.Read", "pet").Run()
assert.NotNil(t, res) assert.NotNil(t, res)
assert.Equal(t, "::Pet Admin", res.(map[string]interface{})["name"]) assert.Contains(t, res.(string), "::Pet Admin")
} }
func TestProcessList(t *testing.T) { func TestProcessList(t *testing.T) {