-
Notifications
You must be signed in to change notification settings - Fork 246
fix incorrect split for select query #754
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
base: v2
Are you sure you want to change the base?
fix incorrect split for select query #754
Conversation
|
@@ -699,7 +702,7 @@ function mergeSelectWithPrimaryAndPartitionKey( | |||
primaryKeys.trim() !== '' ? splitAndTrimCSV(primaryKeys) : []; | |||
const allKeys = [...partitionKeyArr, ...primaryKeyArr]; | |||
if (typeof select === 'string') { | |||
const selectSplit = splitAndTrimCSV(select); |
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.
This is the root cause, make input:
JSONExtractString(Body, 'object', 'c'),JSONExtractString(Body, 'object', 'note')
become
["JSONExtractString(Body", "'object'", "'c')", "'note')"]
after dedupe set(selectColumns
).
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.
Good find! have we thought about using module like csv-parse? (https://www.npmjs.com/package/csv-parse)
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 checked the csv-parse
, however it does not work well with parentheses and brackets.
Parsing option quote
only works for same character such as: "content"
, and it must at the beginning of the string, ex: "good", err"or".
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.
got it. in this case, I think we want to make sure the unit tests cover all use cases. Does it work with the select field like "foo,bar",field2,field3
as well?
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.
It will split it to:
[
'"foo',
'bar"',
'field2',
'field3'
]
It should works fine if we don't get the input like: "foo,bar","foo,differentBar",field2,field3
and also doing the dedupe.
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 will work on quote stuff, will update PR later.
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.
cool, I'd imagine the return value from the example above is ["foo,bar", "field2", "field3"]
although it's a corner case
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.
update the split function to support single quote and double quote, feel free to check test case.
…-select-breaks-the-app
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
We should also replace |
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.
Great fix. Thank you!
This PR currently has a merge conflict. Please resolve this and then re-add the |
Ref: hdx-1587