Merge pull request #356 from strongloop/fix-discovery

Fix discovery
This commit is contained in:
Raymond Feng 2018-07-12 11:42:32 -07:00 committed by GitHub
commit 1c797f5992
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 8 deletions

View File

@ -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);

View File

@ -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",

11
setup.sh Normal file → Executable file
View File

@ -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

View File

@ -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',

View File

@ -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;
}