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

Fix debug logger messing up queries with % #3566

Merged
merged 1 commit into from Dec 7, 2019
Merged

Fix debug logger messing up queries with % #3566

merged 1 commit into from Dec 7, 2019

Conversation

lorefnon
Copy link
Collaborator

@lorefnon lorefnon commented Dec 7, 2019

Resolves #3564

lib/client.js Outdated
const debugBindings = require('debug')('knex:bindings');

const debugQuery = (sql, txId) => _debugQuery(sql.replace(/%/, '%%'), txId)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't that mess up queries that had %% in them already? or that is not a realistic case? maybe we can limit regexp to just single instances of %?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intended this to be /%/g.

Although I cant imagine a situation where we would have multiple consecutive % in an sql query, if we do, I think we would always want them to be reported as many as there are.

> debug('x')('%foo%')
  x NaNoo%

> debug('x')('%%foo%%')
  x %foo% +0ms

> debug('x')('%foo%'.replace(/%/g, '%%'))
  x %foo% +0ms

> debug('x')('%%foo%%'.replace(/%/g, '%%'))
  x %%foo%% +0ms

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair :)

@kibertoad kibertoad merged commit 65e1a3a into master Dec 7, 2019
@kibertoad kibertoad deleted the #3564 branch December 7, 2019 21:15
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

Successfully merging this pull request may close these issues.

Dynamic LIKE is Impossible
2 participants