diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..bc311bca2 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,36 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Mocha Tests", + "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", + "args": [ + "-u", + "tdd", + "--timeout", + "999999", + "--colors", + "${workspaceFolder}/test" + ], + "env": { + "MYSQL_HOST": "localhost", + "MYSQL_USER": "root", + "MYSQL_PASSWORD": "pass", + "MYSQL_PORT": 3307, + "MYSQL_DATABASE": "testdb" + }, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "program": "${workspaceFolder}/index.js" + } + ] +} diff --git a/lib/mysql.js b/lib/mysql.js index 0deb0f0c9..8376a9a73 100644 --- a/lib/mysql.js +++ b/lib/mysql.js @@ -444,6 +444,12 @@ MySQL.prototype.fromColumnValue = function(prop, val) { lat: val.y, }; break; + case 'ObjectID': + val = new prop.type(val); + break; + case 'Buffer': + val = prop.type(val); + break; case 'List': case 'Array': case 'Object': @@ -453,13 +459,6 @@ MySQL.prototype.fromColumnValue = function(prop, val) { } break; default: - if (!Array.isArray(prop.type) && !prop.type.modelName) { - // Do not convert array and model types - // In juggler 4.x, it requires `new prop.type(val)`, - // but it breaks the Enum factory, since it's not written - // in a Class flavor - val = new prop.type(val); - } break; } } diff --git a/test/mysql.test.js b/test/mysql.test.js index 73d084887..fecbd6b2a 100644 --- a/test/mysql.test.js +++ b/test/mysql.test.js @@ -11,7 +11,7 @@ const List = require('loopback-datasource-juggler/lib/list'); var Post, PostWithStringId, PostWithUniqueTitle, PostWithNumId, Student, db; -// Mock up mongodb ObjectID +// // Mock up mongodb ObjectID function ObjectID(id) { if (!(this instanceof ObjectID)) { return new ObjectID(id);