Remove cdbQueryTablesFromPostgres option, now uses it by default

This commit is contained in:
Raul Ochoa 2015-03-23 14:44:42 +01:00
parent 02bc7b9fbf
commit 07297f6bda
5 changed files with 33 additions and 72 deletions

View File

@ -1,4 +1,3 @@
var sqlApi = require('../sql/sql_api');
var PSQL = require('cartodb-psql');
var step = require('step');
@ -74,56 +73,36 @@ function handleAffectedTablesAndLastUpdatedTimeRows(err, rows, callback) {
QueryTablesApi.prototype.runQuery = function(username, query, queryHandler, callback) {
var self = this;
if (shouldQueryPostgresDirectly()) {
var params = {};
var params = {};
step(
function setAuth() {
self.pgConnection.setDBAuth(username, params, this);
},
function setConn(err) {
if (err) {
throw err;
}
self.pgConnection.setDBConn(username, params, this);
},
function executeQuery(err) {
if (err) {
throw err;
}
var psql = new PSQL({
user: params.dbuser,
pass: params.dbpass,
host: params.dbhost,
port: params.dbport,
dbname: params.dbname
});
psql.query(query, function(err, resultSet) {
resultSet = resultSet || {};
var rows = resultSet.rows || [];
queryHandler(err, rows, callback);
});
step(
function setAuth() {
self.pgConnection.setDBAuth(username, params, this);
},
function setConn(err) {
if (err) {
throw err;
}
);
} else {
step(
function getApiKey() {
self.metadataBackend.getUserMapKey(username, this);
},
function executeQuery(err, apiKey) {
if (err) {
throw err;
}
sqlApi.query(username, apiKey, query, function(err, rows) {
queryHandler(err, rows, callback);
});
self.pgConnection.setDBConn(username, params, this);
},
function executeQuery(err) {
if (err) {
throw err;
}
);
}
var psql = new PSQL({
user: params.dbuser,
pass: params.dbpass,
host: params.dbhost,
port: params.dbport,
dbname: params.dbname
});
psql.query(query, function(err, resultSet) {
resultSet = resultSet || {};
var rows = resultSet.rows || [];
queryHandler(err, rows, callback);
});
}
);
};
@ -135,10 +114,3 @@ function prepareSql(sql) {
.replace(affectedTableRegexCache.pixel_height, '1')
;
}
function shouldQueryPostgresDirectly() {
return global.environment &&
global.environment.enabledFeatures &&
global.environment.enabledFeatures.cdbQueryTablesFromPostgres;
}

View File

@ -23,11 +23,12 @@ var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
['/tiles/layergroup', '/u/localhost/tiles/layergroup'].forEach(function(layergroup_url) {
[true, false].forEach(function(cdbQueryTablesFromPostgresEnabledValue) {
var suiteName = 'multilayer:postgres=' + cdbQueryTablesFromPostgresEnabledValue + ";layergroup_url=" + layergroup_url;
var suiteName = 'multilayer:postgres=layergroup_url=' + layergroup_url;
suite(suiteName, function() {
var cdbQueryTablesFromPostgresEnabledValue = true
var redis_client = redis.createClient(global.environment.redis.port);
var sqlapi_server;
var expected_last_updated_epoch = 1234567890123; // this is hard-coded into SQLAPIEmu
@ -38,7 +39,6 @@ suite(suiteName, function() {
var test_database = test_user + '_db';
suiteSetup(function(done){
global.environment.enabledFeatures = { cdbQueryTablesFromPostgres: cdbQueryTablesFromPostgresEnabledValue };
sqlapi_server = new SQLAPIEmu(global.environment.sqlapi.port, done);
});
@ -1444,4 +1444,3 @@ suite(suiteName, function() {
});
});
});

View File

@ -96,7 +96,6 @@ suite('named_layers', function() {
};
suiteSetup(function(done) {
global.environment.enabledFeatures = {cdbQueryTablesFromPostgres: true};
templateMaps.addTemplate(username, nestedNamedMapTemplate, function(err) {
if (err) {
return done(err);
@ -637,7 +636,6 @@ suite('named_layers', function() {
suiteTeardown(function(done) {
global.environment.enabledFeatures = {cdbQueryTablesFromPostgres: false};
templateMaps.delTemplate(username, nestedNamedMapTemplateName, function(err) {
if (err) {
return done(err);

View File

@ -16,9 +16,9 @@ var serverOptions = require(__dirname + '/../../lib/cartodb/server_options')();
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
[true].forEach(function(cdbQueryTablesFromPostgresEnabledValue) {
var cdbQueryTablesFromPostgresEnabledValue = true;
suite('server:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function() {
suite('server', function() {
var redis_client = redis.createClient(global.environment.redis.port);
var sqlapi_server;
@ -56,7 +56,6 @@ suite('server:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function() {
var test_style_black_210 = "#test_table{marker-fill:black;marker-line-color:red;marker-width:20}";
suiteSetup(function(done){
global.environment.enabledFeatures = { cdbQueryTablesFromPostgres: cdbQueryTablesFromPostgresEnabledValue };
sqlapi_server = new SQLAPIEmu(global.environment.sqlapi.port, done);
});
@ -1090,5 +1089,3 @@ suite('server:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function() {
});
});
});

View File

@ -25,9 +25,7 @@ var serverOptions = ServerOptions();
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
[true, false].forEach(function(cdbQueryTablesFromPostgresEnabledValue) {
suite('template_api:postgres=' + cdbQueryTablesFromPostgresEnabledValue, function() {
suite('template_api', function() {
serverOptions.channelCache = {};
var redis_client = redis.createClient(global.environment.redis.port);
@ -36,7 +34,6 @@ suite('template_api:postgres=' + cdbQueryTablesFromPostgresEnabledValue, functio
var expected_last_updated = new Date(expected_last_updated_epoch).toISOString();
suiteSetup(function(done){
global.environment.enabledFeatures = { cdbQueryTablesFromPostgres: cdbQueryTablesFromPostgresEnabledValue };
sqlapi_server = new SQLAPIEmu(global.environment.sqlapi.port, done);
// TODO: check redis is clean ?
});
@ -2121,5 +2118,3 @@ suite('template_api:postgres=' + cdbQueryTablesFromPostgresEnabledValue, functio
});
});
});