-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Do not concatenate an array if passed to escapeLiteral #3489
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
Conversation
Deploying node-postgres with Cloudflare Pages Cloudflare Pages
bf59f44
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.
How about throwing a TypeError
? Seems about the same level of breaking change, but potentially less confusing.
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.
that's what i was going to do at first, but after writing a bunch of tests for previously indeterminate behavior, almost everything returned "''"
when passed to this function - numbers, boolean, date, object. The only problem is with things with a .length
property which aren't strings (namely: array). It actually kinda feels more "escapey" to me to just turn your "not a string" into an empty string in the query if you're concatenating in there. But I was definitely only the fence.
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.
Now that you mention those examples... how about casting everything to String
? pg 9?
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.
yeah that isn't a good idea - def breakage, though subtle. tbh whenever I, very rarely, use these functions to concatenate some form of user-input into a query directly I do a ton of external sanitization first. Check types, if its a number make sure its in an expected range, etc. It's scary & should be a last resort in most cases.
Uh oh!
There was an error while loading. Please reload this page.
null
orundefined
.length