const sqlQueryFail = this.createQueryBuilder('bathingspot')
// .where(`"bathingspot"."userId" = ${userId}`)
.where('bathingspot.userId = :id', {id: userId})
.andWhere('bathingspot.id = :id', {id: spotId}).getSql();
console.log('failing query 1', sqlQueryFail);
failing query
SELECT "bathingspot"."id" AS "bathingspot_id", "bathingspot"."name" AS "bathingspot_name", "bathingspot"."isPublic" AS "bathingspot_isPublic", "bathingspot"."apiEndpoints" AS "bathingspot_apiEndpoints", "bathingspot"."state" AS "bathingspot_state", "bathingspot"."location" AS "bathingspot_location", "bathingspot"."latitude" AS "bathingspot_latitude", "bathingspot"."longitude" AS "bathingspot_longitude", "bathingspot"."elevation" AS "bathingspot_elevation", "bathingspot"."userId" AS "bathingspot_userId", "bathingspot"."regionId" AS "bathingspot_regionId" FROM "bathingspot" "bathingspot" WHERE "bathingspot"."userId" = $1 AND "bathingspot"."id" = $2
const sqlQueryFail = this.createQueryBuilder('bathingspot')
.where(`"bathingspot"."userId" = ${userId}`)
//.where('bathingspot.userId = :id', {id: userId})
.andWhere('bathingspot.id = :id', {id: spotId}).getSql();
console.log('failing query 1', sqlQueryFail);
working query
SELECT "bathingspot"."id" AS "bathingspot_id", "bathingspot"."name" AS "bathingspot_name", "bathingspot"."isPublic" AS "bathingspot_isPublic", "bathingspot"."apiEndpoints" AS "bathingspot_apiEndpoints", "bathingspot"."state" AS "bathingspot_state", "bathingspot"."location" AS "bathingspot_location", "bathingspot"."latitude" AS "bathingspot_latitude", "bathingspot"."longitude" AS "bathingspot_longitude", "bathingspot"."elevation" AS "bathingspot_elevation", "bathingspot"."userId" AS "bathingspot_userId", "bathingspot"."regionId" AS "bathingspot_regionId" FROM "bathingspot" "bathingspot" WHERE "bathingspot"."userId" = 2 AND "bathingspot"."id" = $1