diff --git a/lib/discovery.js b/lib/discovery.js index b238a43..e89e7d4 100644 --- a/lib/discovery.js +++ b/lib/discovery.js @@ -35,7 +35,7 @@ function mixinDiscovery(MySQL) { + ' FROM information_schema.tables WHERE table_schema=\'' + owner + '\'', 'table_schema, table_name', options); } else { sqlTables = paginateSQL('SELECT \'table\' AS "type", table_name AS "name",' - + ' SUBSTRING_INDEX(USER(), \'@\', 1) AS "owner" FROM information_schema.tables', + + ' table_schema AS "owner" FROM information_schema.tables', 'table_name', options); } return sqlTables; @@ -62,7 +62,7 @@ function mixinDiscovery(MySQL) { 'table_schema, table_name', options); } else { sqlViews = paginateSQL('SELECT \'view\' AS "type", table_name AS "name",' - + ' SUBSTRING_INDEX(USER(), \'@\', 1) AS "owner" FROM information_schema.views', + + ' table_schema AS "owner" FROM information_schema.views', 'table_name', options); } } @@ -164,7 +164,7 @@ function mixinDiscovery(MySQL) { + (table ? ' AND table_name=\'' + table + '\'' : ''), 'table_name, ordinal_position', {}); } else { - sql = paginateSQL('SELECT SUBSTRING_INDEX(USER(), \'@\', 1) AS "owner", table_name AS "tableName", column_name AS "columnName", data_type AS "dataType",' + sql = paginateSQL('SELECT table_schema AS "owner", table_name AS "tableName", column_name AS "columnName", data_type AS "dataType",' + ' character_octet_length AS "dataLength", numeric_precision AS "dataPrecision", numeric_scale AS "dataScale", is_nullable AS "nullable"' + ' FROM information_schema.columns' + (table ? ' WHERE table_name=\'' + table + '\'' : ''),