Do not calculate affected tables when there are no affacted tables

This commit is contained in:
Daniel García Aubert
2018-03-12 12:33:29 +01:00
parent e7067ab9cf
commit 25931a618b
+16 -10
View File
@@ -516,22 +516,28 @@ function getAffectedTables (layergroupAffectedTables, pgConnection) {
return next();
}
const sql = [];
mapconfig.getLayers().forEach(function(layer) {
sql.push(layer.options.sql);
if (layer.options.affected_tables) {
layer.options.affected_tables.map(function(table) {
sql.push(`SELECT * FROM ${table} LIMIT 0`);
});
}
});
const sql = queries.length ? queries.join(';') : null;
if (!sql) {
return next();
}
pgConnection.getConnection(user, (err, connection) => {
if (err) {
global.logger.warn('ERROR generating cache channel:', err);
return next();
}
const sql = [];
mapconfig.getLayers().forEach(function(layer) {
sql.push(layer.options.sql);
if (layer.options.affected_tables) {
layer.options.affected_tables.map(function(table) {
sql.push(`SELECT * FROM ${table} LIMIT 0`);
});
}
});
QueryTables.getAffectedTablesFromQuery(connection, sql.join(';'), (err, affectedTables) => {
req.profiler.done('getAffectedTablesFromQuery');
if (err) {