From 1b358c066fd400b2e3d3b6e80107ef23798a2d8a Mon Sep 17 00:00:00 2001 From: Norbert Szmyt Date: Mon, 10 Jun 2024 21:33:02 +0000 Subject: [PATCH] Do not parse on fetch collections for mysql2 --- src/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 06e94fb..ea4ef4b 100644 --- a/src/index.js +++ b/src/index.js @@ -41,7 +41,7 @@ function parse(model, response, options = {}) { export default Bookshelf => { const Model = Bookshelf.Model.prototype; const client = Bookshelf.knex.client.config.client; - const parseOnFetch = client === 'sqlite' || client === 'sqlite3' || client === 'mysql'; + const parseOnFetch = client === 'sqlite' || client === 'sqlite3' || client === 'mysql' || client !== 'mysql2'; Bookshelf.Model = Bookshelf.Model.extend({ initialize() { @@ -108,9 +108,11 @@ export default Bookshelf => { // Parse JSON columns after collection is fetched. this.on('fetched', collection => { - collection.models.forEach(model => { - parse.apply(model); - }); + if (client !== 'mysql2') { + collection.models.forEach(model => { + parse.apply(model); + }); + } }); return Collection.initialize.apply(this, arguments);