mirror of
https://github.com/mariadb-corporation/mariadb-connector-nodejs.git
synced 2025-08-13 13:29:40 +00:00
[CONJS-108] typescript escape/escapeId definition
This commit is contained in:
32
types/index.d.ts
vendored
32
types/index.d.ts
vendored
@ -491,6 +491,22 @@ export interface Connection {
|
||||
*/
|
||||
debugCompress(value: boolean): void;
|
||||
|
||||
/**
|
||||
* This function permit to escape a parameter properly according to parameter type to avoid injection.
|
||||
* @param value parameter
|
||||
*/
|
||||
escape(value: any): string;
|
||||
|
||||
/**
|
||||
* This function permit to escape a Identifier properly . See Identifier Names for escaping. Value will be enclosed by '`' character if content doesn't satisfy:
|
||||
* <OL>
|
||||
* <LI>ASCII: [0-9,a-z,A-Z$_] (numerals 0-9, basic Latin letters, both lowercase and uppercase, dollar sign, underscore)</LI>
|
||||
* <LI>Extended: U+0080 .. U+FFFF and escaping '`' character if needed.</LI>
|
||||
* </OL>
|
||||
* @param identifier identifier
|
||||
*/
|
||||
escapeId(identifier: string): string;
|
||||
|
||||
on(ev: 'end', callback: () => void): Connection;
|
||||
on(ev: 'error', callback: (err: MariaDbError) => void): Connection;
|
||||
}
|
||||
@ -544,6 +560,22 @@ export interface Pool {
|
||||
* Get current stacked connection request.
|
||||
*/
|
||||
taskQueueSize(): number;
|
||||
|
||||
/**
|
||||
* This function permit to escape a parameter properly according to parameter type to avoid injection.
|
||||
* @param value parameter
|
||||
*/
|
||||
escape(value: any): string;
|
||||
|
||||
/**
|
||||
* This function permit to escape a Identifier properly . See Identifier Names for escaping. Value will be enclosed by '`' character if content doesn't satisfy:
|
||||
* <OL>
|
||||
* <LI>ASCII: [0-9,a-z,A-Z$_] (numerals 0-9, basic Latin letters, both lowercase and uppercase, dollar sign, underscore)</LI>
|
||||
* <LI>Extended: U+0080 .. U+FFFF and escaping '`' character if needed.</LI>
|
||||
* </OL>
|
||||
* @param identifier identifier
|
||||
*/
|
||||
escapeId(identifier: string): string;
|
||||
}
|
||||
|
||||
export interface FilteredPoolCluster {
|
||||
|
@ -111,6 +111,10 @@ async function testMisc(): Promise<void> {
|
||||
console.log('ended');
|
||||
|
||||
connection.destroy();
|
||||
connection.escape('test');
|
||||
connection.escape(true);
|
||||
connection.escape(5);
|
||||
connection.escapeId('myColumn');
|
||||
|
||||
await createConnection({ multipleStatements: true });
|
||||
|
||||
@ -167,6 +171,11 @@ async function testPool(): Promise<void> {
|
||||
pool = createPool();
|
||||
|
||||
const connection = await pool.getConnection();
|
||||
pool.escape('test');
|
||||
pool.escape(true);
|
||||
pool.escape(5);
|
||||
pool.escapeId('myColumn');
|
||||
|
||||
console.log(connection.threadId != null);
|
||||
|
||||
await connection.query('SELECT 1 + 1 AS solution');
|
||||
|
Reference in New Issue
Block a user