Merge pull request #914 from trheyi/main
fix: Update processRead to return string representation of table data
This commit is contained in:
commit
d3cc034e07
2 changed files with 2 additions and 8 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue