Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logSQL() messing up console if there is binary BLOB param #2

Closed
afriza opened this issue Dec 7, 2022 · 2 comments
Closed

logSQL() messing up console if there is binary BLOB param #2

afriza opened this issue Dec 7, 2022 · 2 comments

Comments

@afriza
Copy link

afriza commented Dec 7, 2022

The logSQL() function caused problem in the console when I inserted binary BLOB and ExecLogFunc is set to print the SQL.

dbx/query.go

Lines 109 to 110 in cecf5a8

} else if bs, ok := v.([]byte); ok {
sv = "'" + strings.Replace(string(bs), "'", "''", -1) + "'"

For now, in ExecLogFunc I check using string matching if the SQL is involving binary BLOB and don't print it to console.

ganigeorgiev added a commit that referenced this issue Jan 26, 2023
@ganigeorgiev
Copy link
Member

ganigeorgiev commented Jan 26, 2023

I've updated the default logger in v1.9 to print the raw bytes as hex since that is how most db tools (including sqlite3 with mode .quote) seems to handle it.

@afriza
Copy link
Author

afriza commented Jan 28, 2023

Thank you.

Even better, maybe in future, if there's a max limit..

I saw some go logs showing initial & last few number of bytes as hex.. and the middle shows something like [... 5678 bytes of data ... ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants