This is a pretty basic problem, but after some research, I am still scratching my head around what's going on with the WHERE condition not being respected.
Here's the query:
const sql = `SELECT id FROM employees WHERE LOWER(email) = LOWER($1);`;
const { rows } = await query(sql, [email]);
The email parameter is being passed in the function, but when this executes in the app, it returns no records. But when I run the following in DBViz it does work...so it must be something with the LOWER function wrapping the $1 parameter.
DBViz query:
SELECT id FROM employees WHERE LOWER(email) = LOWER('test@acme.com');
I could .toLowerCase() the email variable prior to passing it to the query params, but would love for the DB to handle all this. Any ideas?
Hey Brian - the PG library is fantastic!
This is a pretty basic problem, but after some research, I am still scratching my head around what's going on with the WHERE condition not being respected.
Here's the query:
The email parameter is being passed in the function, but when this executes in the app, it returns no records. But when I run the following in DBViz it does work...so it must be something with the LOWER function wrapping the $1 parameter.
DBViz query:
SELECT id FROM employees WHERE LOWER(email) = LOWER('test@acme.com');
I could
.toLowerCase()
the email variable prior to passing it to the query params, but would love for the DB to handle all this. Any ideas?Thanks for the help!