Add escapeLiteral and escapeIdentifier functions #396
Closed
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.
I needed to be able to escape SQL identifiers (table names, column names, etc), so I added
escapeLiteral
andescapeIdentifier
. There is a native and JS version. Below is an example usage.I am unsure the bindings C code is 100% correct. Particularly how errors are handled. The functions are synchronous so not sure I did the right thing for error handling. As far as I know, the native functions do not perform any I/O only string manipulation which is why I made them synchronous.
I would appreciate it if someone double checked my C to JS port of PQescapeLiteral and PQescapeIdentifier starting on line 3238.
http://doxygen.postgresql.org/fe-exec_8c_source.html
I added tests for both JS and native, but I am unable to run the native tests. It tells me that it cannot find node-gyp, any ideas?