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

Document escapeLiteral and escapeIdentifier #1978

Closed
jmm opened this issue Sep 19, 2019 · 1 comment
Closed

Document escapeLiteral and escapeIdentifier #1978

jmm opened this issue Sep 19, 2019 · 1 comment

Comments

@jmm
Copy link

jmm commented Sep 19, 2019

Hello, thanks for the work on this.

I'm new to this library and was surprised not to be finding any escaping functions. But I managed to find #396.

It seems these are part of the public API and just seemingly aren't documented, so if that's correct this is a request to document them.

Also, since Pool otherwise appears to be a superset of the Client API, would it make sense for them to be available there as well?

Thanks

@brianc
Copy link
Owner

brianc commented Nov 20, 2019

The docs are open source and open to contribution, would love to help you add docs about this over there! https://github.com/brianc/node-postgres-docs

As far as adding it to pool as well? Nah, I thinking having only 1 place to access a function is probably overall easier to reason about than putting it on the pool as well though I'll admit having those functions be on the client prototype was a weird decision made long ago. Probably should just be exported as top level funcs or something nowadays...but anyways it is what it is.

One thing to note about escaping parameters - you're better off using parameterized SQL. I realize that's not always an option.

@brianc brianc closed this as completed Nov 20, 2019
TheConner added a commit to TheConner/node-postgres that referenced this issue Apr 10, 2023
Per brianc#1978 it seems that these client APIs are undocumented. Added documentation for these functions along with some examples and relevant links.
TheConner added a commit to TheConner/node-postgres that referenced this issue Apr 10, 2023
Per brianc#1978 it seems that these client APIs are undocumented. Added documentation for these functions along with some examples and relevant links.
brianc pushed a commit that referenced this issue May 2, 2023
* Document client.escapeIdentifier and client.escapeLiteral

Per #1978 it seems that these client APIs are undocumented. Added documentation for these functions along with some examples and relevant links.

* Fix typos in new docs

* Migrate escapeIdentifier and escapeLiteral from Client to PG

These are standalone utility functions, they do not need a client instance to function.

Changes made:
- Refactored escapeIdentifer and escapeLiteral from client class to functions in utils
- Update PG to export  escapeIdentifier and escapeLiteral
- Migrated tests for Client.escapeIdentifier and Client.escapeLiteral to tests for utils
- Updated documentation, added a "utilities" page where these helpers are discussed

**note** this is a breaking change. Users who used these functions (previously undocumented) on instances of Client, or via Client.prototype.

* Export escapeIdentifier and escapeLiteral from PG

These are standalone utility functions, they should not depend on a client instance.

Changes made:
- Refactored escapeIdentifer and escapeLiteral from client class to functions in utils
- Re-exported functions on client for backwards compatibility
- Update PG to export  escapeIdentifier and escapeLiteral
- Updated tests to validate the newly exported functions from both entry points
- Updated documentation, added a "utilities" page where these helpers are discussed

* Ensure escape functions work via Client.prototype

Updated changes such that escapeIdentifier and escapeLiteral are usable via the client prototype
Updated tests to check for both entry points in client
thijs pushed a commit to thijs/node-postgres that referenced this issue Aug 1, 2023
* Document client.escapeIdentifier and client.escapeLiteral

Per brianc#1978 it seems that these client APIs are undocumented. Added documentation for these functions along with some examples and relevant links.

* Fix typos in new docs

* Migrate escapeIdentifier and escapeLiteral from Client to PG

These are standalone utility functions, they do not need a client instance to function.

Changes made:
- Refactored escapeIdentifer and escapeLiteral from client class to functions in utils
- Update PG to export  escapeIdentifier and escapeLiteral
- Migrated tests for Client.escapeIdentifier and Client.escapeLiteral to tests for utils
- Updated documentation, added a "utilities" page where these helpers are discussed

**note** this is a breaking change. Users who used these functions (previously undocumented) on instances of Client, or via Client.prototype.

* Export escapeIdentifier and escapeLiteral from PG

These are standalone utility functions, they should not depend on a client instance.

Changes made:
- Refactored escapeIdentifer and escapeLiteral from client class to functions in utils
- Re-exported functions on client for backwards compatibility
- Update PG to export  escapeIdentifier and escapeLiteral
- Updated tests to validate the newly exported functions from both entry points
- Updated documentation, added a "utilities" page where these helpers are discussed

* Ensure escape functions work via Client.prototype

Updated changes such that escapeIdentifier and escapeLiteral are usable via the client prototype
Updated tests to check for both entry points in client
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

No branches or pull requests

2 participants