Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Fixed broken functionalities when running on Python2 #263
Fixed broken functionalities when running on Python2 #263
Changes from all commits
227a8ee
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't add a
u
string prefix and assume unicode?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can put
u
in front of'''
for making unicode. But we still neednormalize()
method for removing unintended spaces.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we didn't need these replace and substitutions before. Why now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed some of our code recognized the type of command by looking at a word before the first space character. For example:
This assumes the word before the first space character is keyword of command (very fragile). Unfortunately we have methods that returns sql with bunch of leading white spaces. For example:
This method returns a string:
The word before the first space is
\n
that is recognized as a command keyword. This not intended. And the leading\n
prevents to strip all the white spaces in front of actual keyword. For example,sql.strip().startswith('SELECT')
is false. And this way of peeking keyword is actually exists in our code.It seems this behavior did not break existing functionality, and I guess it was because that type of parsing was only done for special command which starts with
\\
. (Neither\n
orSELECT
is special command so it has returned false anyway and did not break functionality -- working code relying on a bug.)However, I still believe we should return a sql with correct format since there is an evidence authors assume the first word is a keyword for command.
The
normalize()
method I wrote converts the raw format into correct format like: