mysqljs / mysql

A pure node.js JavaScript Client implementing the MySQL protocol.
MIT License
18.27k stars 2.52k forks source link

Improve the custom format example to support escapeId() placeholder #2531

Closed gilzarfati closed 2 years ago

gilzarfati commented 2 years ago

Hi, The custom format example given today: https://www.npmjs.com/package/mysql#custom-format

Only offers an alternative for the ? place holder. I think it will be better to provide a more complete example that also supports the ?? placeholder for escapeId().

For example: connection.query("SELECT * FROM ::table WHERE ::column = :tiltle", { table: "posts", column: "title", title: "Hello MySQL" });

Where : will be used for escape() as it is today and :: will be used for escapedId()

This way the example will have the complete functionality of the default one.

Thanks

dougwilson commented 2 years ago

Thanks for the feedback. The only goal of the example is just that: an example for how to use the custom format API, as the point is for folks to make their own. If you would like to make improvements to it, please make a pull request 👍 .