From be599b9347e5510e0da5cf23b1c4ec4933d64916 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Thu, 12 Jul 2018 10:42:19 -0700 Subject: [PATCH 1/3] use "owner" for discovered results --- lib/discovery.js | 2 +- test/mysql.discover.test.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/discovery.js b/lib/discovery.js index c148cc0..27d1497 100644 --- a/lib/discovery.js +++ b/lib/discovery.js @@ -67,7 +67,7 @@ function mixinDiscovery(MySQL, mysql) { 'table_schema, table_name', options); } else if (schema) { sqlTables = paginateSQL('SELECT \'table\' AS "type",' + - ' table_name AS "name", table_schema AS "schema"' + + ' table_name AS "name", table_schema AS "owner"' + ' FROM information_schema.tables' + ' WHERE table_schema=' + mysql.escape(schema), 'table_schema, table_name', options); diff --git a/test/mysql.discover.test.js b/test/mysql.discover.test.js index 6ccf6dd..c12cb19 100644 --- a/test/mysql.discover.test.js +++ b/test/mysql.discover.test.js @@ -69,7 +69,7 @@ describe('discoverModels', function() { var views = false; assert(models.length > 0, 'some models returned'); models.forEach(function(m) { - assert.equal(m.schema.toLowerCase(), config.database.toLowerCase()); + assert.equal(m.owner.toLowerCase(), config.database.toLowerCase()); }); done(null, models); } @@ -112,6 +112,7 @@ describe('Discover models including other users', function() { var others = false; assert.equal(3, models.length); models.forEach(function(m) { + assert(m.owner); if (m.owner !== 'STRONGLOOP') { others = true; } From c97fdf39b49ed4ba4c0d630259ba6d01baf42dc1 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Thu, 12 Jul 2018 10:43:00 -0700 Subject: [PATCH 2/3] pin mysql image to 5.7 See https://github.com/mysqljs/mysql/issues/2002 --- setup.sh | 11 ++++++++--- test/init.js | 1 - 2 files changed, 8 insertions(+), 4 deletions(-) mode change 100644 => 100755 setup.sh diff --git a/setup.sh b/setup.sh old mode 100644 new mode 100755 index 7eb3361..1801fbc --- a/setup.sh +++ b/setup.sh @@ -48,14 +48,19 @@ printf "\n${RED}>> Finding old builds and cleaning up${PLAIN} ${GREEN}...${PLAIN docker rm -f $MYSQL_CONTAINER > /dev/null 2>&1 printf "\n${CYAN}Clean up complete.${PLAIN}\n" +## Pin mysql docker image to version as `mysql` node.js driver does not support v8 yet +## See https://github.com/mysqljs/mysql/issues/2002 +DOCKER_IMAGE=mysql:5.7.22 + ## pull latest mysql image -printf "\n${RED}>> Pulling latest mysql image${PLAIN} ${GREEN}...${PLAIN}" -docker pull mysql:latest > /dev/null 2>&1 +printf "\n${RED}>> Pulling ${DOCKER_IMAGE} image${PLAIN} ${GREEN}...${PLAIN}" + +docker pull ${DOCKER_IMAGE} > /dev/null 2>&1 printf "\n${CYAN}Image successfully built.${PLAIN}\n" ## run the mysql container printf "\n${RED}>> Starting the mysql container${PLAIN} ${GREEN}...${PLAIN}" -CONTAINER_STATUS=$(docker run --name $MYSQL_CONTAINER -e MYSQL_ROOT_USER=$USER -e MYSQL_ROOT_PASSWORD=$PASSWORD -p $PORT:3306 -d mysql:latest 2>&1) +CONTAINER_STATUS=$(docker run --name $MYSQL_CONTAINER -e MYSQL_ROOT_USER=$USER -e MYSQL_ROOT_PASSWORD=$PASSWORD -p $PORT:3306 -d ${DOCKER_IMAGE} 2>&1) if [[ "$CONTAINER_STATUS" == *"Error"* ]]; then printf "\n\n${CYAN}Status: ${PLAIN}${RED}Error starting container. Terminating setup.${PLAIN}\n\n" exit 1 diff --git a/test/init.js b/test/init.js index 8948751..831f467 100644 --- a/test/init.js +++ b/test/init.js @@ -10,7 +10,6 @@ module.exports = require('should'); var DataSource = require('loopback-datasource-juggler').DataSource; var config = require('rc')('loopback', {test: {mysql: {}}}).test.mysql; -console.log(config); global.getConfig = function(options) { var dbConf = { host: process.env.MYSQL_HOST || config.host || 'localhost', From ea93cc87353fc7c3c71bb850bf1b5b0dbed4604a Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Thu, 12 Jul 2018 11:08:51 -0700 Subject: [PATCH 3/3] upgrade deps --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 15b2640..399f9d5 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "5.2.0", "description": "MySQL connector for loopback-datasource-juggler", "engines": { - "node": ">=4" + "node": ">=6" }, "main": "index.js", "scripts": { @@ -13,7 +13,7 @@ "posttest": "npm run lint" }, "dependencies": { - "async": "^0.9.0", + "async": "^2.6.1", "debug": "^3.1.0", "lodash": "^4.17.4", "loopback-connector": "^4.0.0",