Skip to content

Commit

Permalink
ADD query pointer log.
Browse files Browse the repository at this point in the history
  • Loading branch information
karminski committed Feb 19, 2024
1 parent eb81d1f commit 5d66972
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/actionruntime/mysql/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"errors"
"fmt"
"log"
"time"

"github.com/go-playground/validator/v10"
Expand Down Expand Up @@ -140,15 +141,18 @@ func (m *MySQLConnector) Run(resourceOptions map[string]interface{}, actionOptio

// fetch data
if isSelectQuery && m.Action.IsSafeMode() {
log.Printf("[DUMP] db.QueryContext() sql: %s\n", escapedSQL)
rows, err := db.QueryContext(ctx, escapedSQL, sqlArgs...)
if err != nil {
return queryResult, err
}
log.Printf("[DUMP] common.RetrieveToMap start.\n")
mapRes, err := common.RetrieveToMap(rows)
if err != nil {
return queryResult, err
}
defer rows.Close()
log.Printf("[DUMP] common.RetrieveToMap done.\n")
queryResult.Success = true
queryResult.Rows = mapRes
} else if isSelectQuery && !m.Action.IsSafeMode() {
Expand Down
5 changes: 5 additions & 0 deletions src/actionruntime/postgresql/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"errors"
"fmt"
"log"
"time"

"github.com/illacloud/builder-backend/src/actionruntime/common"
Expand Down Expand Up @@ -146,15 +147,19 @@ func (p *Connector) Run(resourceOptions map[string]interface{}, actionOptions ma

// fetch data
if isSelectQuery && p.Action.IsSafeMode() {
log.Printf("[DUMP] db.Query() sql: %s\n", escapedSQL)
rows, err := db.Query(ctx, escapedSQL, sqlArgs...)
if err != nil {
return queryResult, err
}
log.Printf("[DUMP] common.RetrieveToMap start.\n")
mapRes, err := RetrieveToMap(rows)
if err != nil {
return queryResult, err
}
defer rows.Close()
log.Printf("[DUMP] common.RetrieveToMap end.\n")

queryResult.Success = true
queryResult.Rows = mapRes
} else if isSelectQuery && !p.Action.IsSafeMode() {
Expand Down

0 comments on commit 5d66972

Please sign in to comment.