Replies: 1 comment
-
You can always: // Build the query first
q := db.NewInsert().Model(...).Set(...)
// Log the complete query to debug it
fmt.Printf(q.String())
// Execute later
if _, err := q.Exec(); err != nil {
// handle error
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am a new user of Bun (and a false beginner in SQL for that matter), I am trying to use a rather complex
INSERT
that fails.My database connection is initialized into a global variable used across my code:
(I am still not sure what
ctx
is for (I could not find anything in the docs, but it works)Another, related DB query (a helper database) does show the trace of the request for a
NewSelect()
- that query and the whole setup (similar to the one I showed above:Open()
,NewDB()
, ...) is within one function. The trace is as expected:A
NewInsert()
query againstdb
(the global variable) works but does not show the trace. It runs with an errorand I would be glad to see the whole
INSERT
to understand where the problem is.My question: is the trace visible only after a successful request (a
nil
error returned)? If so: is there a way to debug the SQL command that is actually built?EDIT: I do not see the trace even with a successful (error
nil
) request.Beta Was this translation helpful? Give feedback.
All reactions