Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Vladimir Barsukov
zGo
Commits
dc8c5cd4
Commit
dc8c5cd4
authored
Mar 10, 2024
by
Vladimir Barsukov
Browse files
debug sql
parent
168e879e
Changes
1
Hide whitespace changes
Inline
Side-by-side
zdb/pool.go
View file @
dc8c5cd4
...
...
@@ -38,6 +38,7 @@ type Pool struct {
Balance
Balance
PingTimout
time
.
Duration
PingTry
int
Debug
bool
}
func
(
d
*
Pool
)
WithContext
(
ctx
context
.
Context
)
*
Pool
{
...
...
@@ -417,19 +418,21 @@ func (d *Pool) prepare(sql string, param map[string]any) string {
}
}
if
v
,
ok
:=
param
[
"_debug"
];
ok
{
if
d
.
Debug
{
d
.
logger
.
Printf
(
"--SQL
\n
%v
\n
--SQL;
\n
--ARG
\n
%+v
\n
--ARG;"
,
sql
,
param
)
}
else
if
v
,
ok
:=
param
[
"_debug"
];
ok
{
switch
vv
:=
v
.
(
type
)
{
case
bool
:
if
vv
{
d
.
logger
.
Printf
(
sql
)
d
.
logger
.
Printf
(
"--SQL
\n
%v
\n
--SQL;
\n
--ARG
\n
%+v
\n
--ARG;"
,
sql
,
param
)
}
case
int
,
uint
:
if
vv
==
1
{
d
.
logger
.
Printf
(
sql
)
d
.
logger
.
Printf
(
"--SQL
\n
%v
\n
--SQL;
\n
--ARG
\n
%+v
\n
--ARG;"
,
sql
,
param
)
}
case
string
:
if
vv
==
"1"
{
d
.
logger
.
Printf
(
sql
)
d
.
logger
.
Printf
(
"--SQL
\n
%v
\n
--SQL;
\n
--ARG
\n
%+v
\n
--ARG;"
,
sql
,
param
)
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment