首页 > 解决方案 > 使用原始查询时,Sequelize 无法识别带有 camelCase 名称的表

问题描述

我在 sequelize 中使用原始查询来查询具有骆驼案例名称的表中的数据。代码看起来像这样

 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;

sequelize 似乎无法识别带有驼峰字母的表名。它不是查找“productDefinitions”,而是查找“productdefinitions”,这是输出

Error: relation "productdefinitions" does not exist

标签: javascriptsequelize.js

解决方案


我想你正在使用 Postgres。尝试用"


推荐阅读