Skip to content

Commit

Permalink
fix some minor points
Browse files Browse the repository at this point in the history
  • Loading branch information
zztkm committed Apr 24, 2024
1 parent cef5b9b commit 33abcb5
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions cloudflare/d1/stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (s *stmt) QueryContext(_ context.Context, args []driver.NamedValue) (driver
for i, arg := range args {
argValues[i] = arg.Value
}
resultPromise := s.stmtObj.Call("bind", argValues...).Call("raw", map[string]interface{}{"columnNames": true})
resultPromise := s.stmtObj.Call("bind", argValues...).Call("raw", map[string]any{"columnNames": true})
rowsObj, err := jsutil.AwaitPromise(resultPromise)
if err != nil {
return nil, err
Expand All @@ -70,19 +70,19 @@ func (s *stmt) QueryContext(_ context.Context, args []driver.NamedValue) (driver
columns: nil,
rowsObj: rowsObj,
}, nil
} else {
// The first result array includes the column names.
colsArray := rowsObj.Index(0)
colsLen := colsArray.Length()
cols := make([]string, colsLen)
for i := 0; i < colsLen; i++ {
cols[i] = colsArray.Index(i).String()
}
// Remove the first result array from the rowsObj.
rowsObj.Call("shift")
return &rows{
columns: cols,
rowsObj: rowsObj,
}, nil
}

// The first result array includes the column names.
colsArray := rowsObj.Index(0)
colsLen := colsArray.Length()
cols := make([]string, colsLen)
for i := 0; i < colsLen; i++ {
cols[i] = colsArray.Index(i).String()
}
// Remove the first result array from the rowsObj.
rowsObj.Call("shift")
return &rows{
columns: cols,
rowsObj: rowsObj,
}, nil
}

0 comments on commit 33abcb5

Please sign in to comment.