# generated by patch-package 6.4.14 # # declared package: # mysql2: 3.11.3 # diff --git a/node_modules/mysql2/lib/connection.js b/node_modules/mysql2/lib/connection.js index af6b3d9..a427374 100644 --- a/node_modules/mysql2/lib/connection.js +++ b/node_modules/mysql2/lib/connection.js @@ -32,7 +32,7 @@ const CharsetToEncoding = require('./constants/charset_encodings.js'); let _connectionId = 0; -let convertNamedPlaceholders = null; +// let convertNamedPlaceholders = null; class Connection extends EventEmitter { constructor(opts) { @@ -524,7 +524,7 @@ class Connection extends EventEmitter { sql: sql, values: values }; - this._resolveNamedPlaceholders(opts); + // this._resolveNamedPlaceholders(opts); return SqlString.format( opts.sql, opts.values, @@ -546,20 +546,20 @@ class Connection extends EventEmitter { } _resolveNamedPlaceholders(options) { - let unnamed; - if (this.config.namedPlaceholders || options.namedPlaceholders) { - if (Array.isArray(options.values)) { - // if an array is provided as the values, assume the conversion is not necessary. - // this allows the usage of unnamed placeholders even if the namedPlaceholders flag is enabled. - return - } - if (convertNamedPlaceholders === null) { - convertNamedPlaceholders = require('named-placeholders')(); - } - unnamed = convertNamedPlaceholders(options.sql, options.values); - options.sql = unnamed[0]; - options.values = unnamed[1]; - } + // let unnamed; + // if (this.config.namedPlaceholders || options.namedPlaceholders) { + // if (Array.isArray(options.values)) { + // // if an array is provided as the values, assume the conversion is not necessary. + // // this allows the usage of unnamed placeholders even if the namedPlaceholders flag is enabled. + // return + // } + // if (convertNamedPlaceholders === null) { + // convertNamedPlaceholders = require('named-placeholders')(); + // } + // unnamed = convertNamedPlaceholders(options.sql, options.values); + // options.sql = unnamed[0]; + // options.values = unnamed[1]; + // } } query(sql, values, cb) { @@ -569,7 +569,7 @@ class Connection extends EventEmitter { } else { cmdQuery = Connection.createQuery(sql, values, cb, this.config); } - this._resolveNamedPlaceholders(cmdQuery); + // this._resolveNamedPlaceholders(cmdQuery); const rawSql = this.format(cmdQuery.sql, cmdQuery.values !== undefined ? cmdQuery.values : []); cmdQuery.sql = rawSql; return this.addCommand(cmdQuery); @@ -644,26 +644,27 @@ class Connection extends EventEmitter { options.sql = sql; options.values = values; } - this._resolveNamedPlaceholders(options); + // this._resolveNamedPlaceholders(options); // check for values containing undefined if (options.values) { //If namedPlaceholder is not enabled and object is passed as bind parameters - if (!Array.isArray(options.values)) { - throw new TypeError( - 'Bind parameters must be array if namedPlaceholders parameter is not enabled' - ); - } + // if (!Array.isArray(options.values)) { + // throw new TypeError( + // 'Bind parameters must be array if namedPlaceholders parameter is not enabled' + // ); + // } options.values.forEach(val => { //If namedPlaceholder is not enabled and object is passed as bind parameters - if (!Array.isArray(options.values)) { - throw new TypeError( - 'Bind parameters must be array if namedPlaceholders parameter is not enabled' - ); - } + // if (!Array.isArray(options.values)) { + // throw new TypeError( + // 'Bind parameters must be array if namedPlaceholders parameter is not enabled' + // ); + // } if (val === undefined) { - throw new TypeError( - 'Bind parameters must not contain undefined. To pass SQL NULL specify JS null' - ); + // throw new TypeError( + // 'Bind parameters must not contain undefined. To pass SQL NULL specify JS null' + // ); + val = null } if (typeof val === 'function') { throw new TypeError( diff --git a/node_modules/mysql2/lib/packets/execute.js b/node_modules/mysql2/lib/packets/execute.js index daf1df9..0862ce1 100644 --- a/node_modules/mysql2/lib/packets/execute.js +++ b/node_modules/mysql2/lib/packets/execute.js @@ -28,7 +28,10 @@ function toParameter(value, encoding, timezone) { if (value !== null) { switch (typeof value) { case 'undefined': - throw new TypeError('Bind parameters must not contain undefined'); + // throw new TypeError('Bind parameters must not contain undefined'); + value = ''; + type = Types.NULL; + break; case 'number': type = Types.DOUBLE; diff --git a/node_modules/mysql2/lib/parsers/binary_parser.js b/node_modules/mysql2/lib/parsers/binary_parser.js index 4eb0d3a..bf6dbec 100644 --- a/node_modules/mysql2/lib/parsers/binary_parser.js +++ b/node_modules/mysql2/lib/parsers/binary_parser.js @@ -77,7 +77,7 @@ function readCodeFor(field, config, options, fieldNum) { default: if (field.characterSet === Charsets.BINARY) { - return 'packet.readLengthCodedBuffer();'; + return '[...packet.readLengthCodedBuffer()];'; } return `packet.readLengthCodedString(fields[${fieldNum}].encoding)`; } @@ -94,6 +94,7 @@ function compile(fields, options, config) { db: field.schema, table: field.table, name: field.name, + charset: field.characterSet, string: function (encoding = field.encoding) { if (field.columnType === Types.JSON && encoding === field.encoding) { // Since for JSON columns mysql always returns charset 63 (BINARY), diff --git a/node_modules/mysql2/lib/parsers/text_parser.js b/node_modules/mysql2/lib/parsers/text_parser.js index deedadf..7a4a6c8 100644 --- a/node_modules/mysql2/lib/parsers/text_parser.js +++ b/node_modules/mysql2/lib/parsers/text_parser.js @@ -90,6 +90,7 @@ function compile(fields, options, config) { db: field.schema, table: field.table, name: field.name, + charset: field.characterSet, string: function (encoding = field.encoding) { if (field.columnType === Types.JSON && encoding === field.encoding) { // Since for JSON columns mysql always returns charset 63 (BINARY), diff --git a/node_modules/mysql2/typings/mysql/lib/parsers/typeCast.d.ts b/node_modules/mysql2/typings/mysql/lib/parsers/typeCast.d.ts index b8e9751..ca8fbda 100644 --- a/node_modules/mysql2/typings/mysql/lib/parsers/typeCast.d.ts +++ b/node_modules/mysql2/typings/mysql/lib/parsers/typeCast.d.ts @@ -44,6 +44,7 @@ export type Field = Type & { db: string; table: string; name: string; + charset: number; string: (encoding?: BufferEncoding | string | undefined) => string | null; buffer: () => Buffer | null; geometry: () => Geometry | Geometry[] | null;