I'm trouble shooting this application that I ave had no hand in creating, but I get to fix. Anywho, I'm finding that I am unable to query the postgres db for any variable that has an _. Now before you say use escape characters, I've already been there, done that, and got the t-shirt. From what I could tell, the application uses escape-string-regexp module to alter the string, for example => "[email protected]" => "some_random@email\.com" I added my own module to single out the _ and now the output is => "some\\_random@email\.com". Note the two escapes for the underscore as prescribed by the mass forums that I have scaled. I even built a tool to test out in python and that works. Slightly different as I use => "(E'some\\_random@email\\.com')". Tried that with javascript as well and still no dice. What say all ye? Oh, this shoots out via expressjs from what I can tell. I'm not a javascript guy.
-
1What's the error you get? you explain the problem but it's needed the actual error that drops the data base or javascript.Dan– Dan2017-08-24 22:05:16 +00:00Commented Aug 24, 2017 at 22:05
-
To be quite honest no error. The query just keeps churning without spitting back results.Darian R.– Darian R.2017-08-25 13:28:15 +00:00Commented Aug 25, 2017 at 13:28
-
Mmm... that's really weird, have you tried looking at the database logs? there has to be some info. If there are no logs, then the problem is not in the database, is elsewhere. Perhaps is not sending the request at all to the database.Dan– Dan2017-08-25 15:52:45 +00:00Commented Aug 25, 2017 at 15:52
Add a comment
|
1 Answer
Found the solution. I and another team mate went back and revisited the method I created and changed the " to '. Next thing you know, it started working.
exports.stringChanger = function(word){
//console.log(word)
var metas = ["_"];
var guestPool = word.split("");
//console.log(guestPool)
for(i in range(guestPool.length)){
for(j in range(metas.length)){
if(guestPool[i] === metas[j]){
guestPool[i] = "\\" + guestPool[i];
}
}
}
var guest = guestPool.join("");
return guest;
//console.log(guest)
};
to
exports.stringChanger = function(word){
//console.log(word)
var metas = ['_'];
var guestPool = word.split("");
//console.log(guestPool)
for(i in range(guestPool.length)){
for(j in range(metas.length)){
if(guestPool[i] === metas[j]){
guestPool[i] = '\\' + guestPool[i];
}
}
}
var guest = guestPool.join("");
return guest;
//console.log(guest)
};