From 125c5ecadb947fe56fd1b43ce2da7a719a749d50 Mon Sep 17 00:00:00 2001 From: Zbynek Rybicka Date: Thu, 30 Aug 2018 12:36:01 +0200 Subject: [PATCH] finding error --- lib/util/data.helper.js | 4 ++++ lib/xsql.js | 37 ++++++++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/lib/util/data.helper.js b/lib/util/data.helper.js index d95b0ee2fa..23ed878434 100644 --- a/lib/util/data.helper.js +++ b/lib/util/data.helper.js @@ -146,6 +146,10 @@ exports.getSchemaQuery = function() { ); }; +exports.getRoutines = function () { + return 'select routine_name from information_schema.routines' +} + exports.getChartQuery = function() { return "select ? as ??, count(*) as _count from ?? where ?? between ? and ? "; }; diff --git a/lib/xsql.js b/lib/xsql.js index 119b0515e1..42255ceea1 100644 --- a/lib/xsql.js +++ b/lib/xsql.js @@ -50,17 +50,23 @@ class Xsql { } } - self.iterateToCacheTables(results) - self.iterateToCacheTablePks(results) - self.iterateToCacheTableColumns(results) - self.iterateToCacheTableFks(results) - self.iterateToCacheRoutines(results) - - // osx mysql server has limitations related to open_tables - self.pool.query("FLUSH TABLES", [], (err, results) => { - cbk(null, null); - }); - } + self.iterateToCacheTables(results) + self.iterateToCacheTablePks(results) + self.iterateToCacheTableColumns(results) + self.iterateToCacheTableFks(results) + self.iterateToCacheRoutines(results) + + // osx mysql server has limitations related to open_tables + self.pool.query('FLUSH TABLES', [], (err, results) => { + self.pool.query(dataHelp.getRoutines(), [this.sqlConfig.database], (err, results) => { + if (err) { + cbk(err, results) + } else { + self.iterateToCacheRoutines(results) + cbk(null, null) + } + }) + }) } ); } @@ -82,6 +88,15 @@ class Xsql { } } + iterateToCacheRoutines(routineResults) { + for (let i = 0; i < routineResults.length; i++) { + const routine = routineResults[i] + const routineName = routine['routine_name'] + this.metaDb.routines[routineName] = {} + } + console.log(JSON.stringify(this.metaDb)) + } + iterateToCacheTableColumns(schemaResults) { for (let i = 0; i < schemaResults.length; ++i) { let schemaRow = schemaResults[i];