Can anyone help me execute a query using nest/typeorm?
I'm utilizing Typeorm's "InjectConnection" to run a raw query in my Postgres Database. The issue arises with the column user_roles_role.userId (note that I am specifying 'userId' in uppercase). Here is the code snippet:
const queryText = `SELECT * FROM user_roles_role WHERE user_roles_role.userId = ${id}`
try {
const rawData = await this.connection.query(queryText);
return rawData;
} catch (err) {
console.log(err);
return err;
}
When running this query, I encounter an error where Typeorm seems to be converting the column name to lowercase, as shown in the Typeorm error message below:
query: 'SELECT * FROM user_roles_role WHERE user_roles_role.userId = 1', parameters: undefined, driverError: error: column user_roles_role.userid does not exist
Things I have attempted:
Using single quotes and double quotes (which didn't work)
Full Error Message:
"query": "SELECT * FROM user_roles_role WHERE user_roles_role.userId = 1", "driverError": { "length": 189, "name": "error", "severity": "ERROR", "code": "42703", "hint": "Perhaps you meant to reference the column >"user_roles_role.userId".", "position": "37", "file": "parse_relation.c", "line": "3599", "routine": "errorMissingColumn" }