MCPcopy Create free account
hub / github.com/cloudwan/gohan / QueryContext

Method QueryContext

db/sql/sql.go:1015–1031  ·  view source on GitHub ↗

Query with raw sql string

(ctx context.Context, s *schema.Schema, query string, arguments []interface{})

Source from the content-addressed store, hash-verified

1013
1014// Query with raw sql string
1015func (tx *Transaction) QueryContext(ctx context.Context, s *schema.Schema, query string, arguments []interface{}) (list []*schema.Resource, err error) {
1016 defer tx.measureTime(time.Now(), s.ID, "query")
1017
1018 tx.logQuery(query, arguments...)
1019 rows, err := tx.transaction.QueryxContext(ctx, query, arguments...)
1020 if err != nil {
1021 return nil, fmt.Errorf("Failed to run query: %s", query)
1022 }
1023
1024 defer rows.Close()
1025 list, err = tx.decodeRows(s, rows, list, false, false)
1026 if err != nil {
1027 return nil, err
1028 }
1029
1030 return
1031}
1032
1033func (tx *Transaction) decodeRows(s *schema.Schema, rows *sqlx.Rows, list []*schema.Resource, skipNil, recursive bool) ([]*schema.Resource, error) {
1034 for rows.Next() {

Callers 1

QueryMethod · 0.95

Calls 5

measureTimeMethod · 0.95
logQueryMethod · 0.95
decodeRowsMethod · 0.95
ErrorfMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected