🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

mysql2

Package Overview
Dependencies
Maintainers
1
Versions
298
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql2 - npm Package Compare versions

Comparing version
3.23.1-canary.7c48343
to
3.23.1
+35
-5
lib/parsers/binary_parser.js

@@ -99,3 +99,3 @@ 'use strict';

function wrap(field, packet) {
function fieldMetadata(field) {
return {

@@ -109,2 +109,8 @@ type: typeNames[field.columnType],

name: field.name,
};
}
function wrap(field, packet) {
return {
...fieldMetadata(field),
string: function (encoding = field.encoding) {

@@ -153,2 +159,18 @@ if (field.columnType === Types.JSON && encoding === field.encoding) {

/** A NULL value carries no bytes in the binary row packet, so the accessors return null without reading from it. */
function wrapNull(field) {
return {
...fieldMetadata(field),
string: function () {
return null;
},
buffer: function () {
return null;
},
geometry: function () {
return null;
},
};
}
parserFn('(function(){');

@@ -202,5 +224,13 @@ parserFn('return class BinaryRow {');

parserFn(`if (nullBitmaskByte${nullByteIndex} & ${currentFieldNullBit}) `);
parserFn(`${lvalue} = null;`);
parserFn('else {');
parserFn(`if (nullBitmaskByte${nullByteIndex} & ${currentFieldNullBit}) {`);
if (typeof options.typeCast === 'function') {
const nullWrapperVar = `nullWrapper${i}`;
parserFn(`const ${nullWrapperVar} = wrapNull(fields[${i}]);`);
parserFn(
`${lvalue} = options.typeCast(${nullWrapperVar}, function() { return null; });`
);
} else {
parserFn(`${lvalue} = null;`);
}
parserFn('} else {');

@@ -241,3 +271,3 @@ if (options.typeCast === false) {

}
return parserFn.toFunction({ wrap });
return parserFn.toFunction({ wrap, wrapNull });
}

@@ -244,0 +274,0 @@

@@ -97,2 +97,24 @@ 'use strict';

/** A NULL value carries no bytes in the binary row packet, so the accessors return null without reading from it. */
function wrapNull(field) {
return {
type: typeNames[field.columnType],
extendedTypeName: field.extendedTypeName,
extendedFormat: field.extendedFormat,
length: field.columnLength,
db: field.schema,
table: field.table,
name: field.name,
string: function () {
return null;
},
buffer: function () {
return null;
},
geometry: function () {
return null;
},
};
}
return class BinaryRow {

@@ -122,3 +144,6 @@ constructor() {}

if (nullBitmaskBytes[nullByteIndex] & currentFieldNullBit) {
value = null;
value =
typeof typeCast === 'function'
? typeCast(wrapNull(field), () => null)
: null;
} else if (options.typeCast === false) {

@@ -125,0 +150,0 @@ value = packet.readLengthCodedBuffer();

+1
-1
{
"name": "mysql2",
"version": "3.23.1-canary.7c48343",
"version": "3.23.1",
"description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",

@@ -5,0 +5,0 @@ "main": "index.js",