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

Set protocolVersion as optional in escape function (TypeScript) #248

Merged
merged 1 commit into from Mar 15, 2021
Merged

Set protocolVersion as optional in escape function (TypeScript) #248

merged 1 commit into from Mar 15, 2021

Conversation

Rafatcb
Copy link
Contributor

@Rafatcb Rafatcb commented Mar 15, 2021

As you can see below, it is already an optional argument, so I'm just fixing TypeScript types.

node-firebird/lib/index.js

Lines 830 to 857 in 9613cd4

/**
* Escape value
* @param {Object} value
* @param {Number} protocolVersion (optional, default: PROTOCOL_VERSION13)
* @return {String}
*/
exports.escape = function(value, protocolVersion) {
if (value === null || value === undefined)
return 'NULL';
switch (typeof(value)) {
case 'boolean':
if ((protocolVersion || PROTOCOL_VERSION13) >= PROTOCOL_VERSION13)
return value ? 'true' : 'false';
else
return value ? '1' : '0';
case 'number':
return value.toString();
case 'string':
return "'" + value.replace(/'/g, "''").replace(/\\/g, '\\\\') + "'";
}
if (value instanceof Date)
return "'" + value.getFullYear() + '-' + (value.getMonth()+1).toString().padLeft(2, '0') + '-' + value.getDate().toString().padLeft(2, '0') + ' ' + value.getHours().toString().padLeft(2, '0') + ':' + value.getMinutes().toString().padLeft(2, '0') + ':' + value.getSeconds().toString().padLeft(2, '0') + '.' + value.getMilliseconds().toString().padLeft(3, '0') + "'";
throw new Error('Escape supports only primitive values.');
};

@mariuz mariuz merged commit 098757b into hgourvest:master Mar 15, 2021
@mariuz
Copy link
Collaborator

mariuz commented Mar 15, 2021

Thank you for contribution !

@Rafatcb Rafatcb deleted the patch-1 branch March 15, 2021 20:55
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

Successfully merging this pull request may close these issues.

None yet

2 participants