I am stuck using a raw query in sequelize to query data from a table with the camel case name. The codes look like this
const activeProducts = await sequelize.query(
`SELECT ap.*, pd.stack_id stack_id, pd.channel_id channel_id, pd.product_type product_type FROM active_products ap
join productDefinitions pd on ap.product_id = pd.id
WHERE active = \'active\'
`,
{ type: QueryTypes.SELECT }
);
console.log(activeProducts)
return activeProducts;
It seems that sequelize does not recognize the table name with camel case letter. Instead of finding 'productDefinitions', it look for 'productdefinitions' and here is the output
Error: relation "productdefinitions" does not exist
I suppose you are using Postgres. Try to wrap the table name with "
Did you try Quoting the table name?
SELECT ap.*, pd.stack_id stack_id, pd.channel_id channel_id, pd.product_type product_type FROM active_products ap
join "productDefinitions" pd on ap.product_id = pd.id
WHERE active = \'active\'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.