简体   繁体   English

使用 Sequelize.query 时出错,查询不区分大小写吗?

[英]Error when using Sequelize.query, is the query not case sensitive?

I get an error when running this query with Sequelize.query:使用 Sequelize.query 运行此查询时出现错误:

sequelize.query( "SELECT hubs.* FROM hubs LEFT JOIN posts ON hubs.id = posts.hubId WHERE posts.userId = ? GROUP BY hubs.id ORDER BY COUNT(posts.id) DESC LIMIT 3", { replacements: [userId], type: QueryTypes.SELECT } )

When i run it I get an error saying:当我运行它时,我收到一条错误消息:

error: column posts.hubid does not exist
hint: 'Perhaps you meant to reference the column "posts.hubId"

As you can se in my query i have written posts.hubId and not posts.hubid as the error says.正如你在我的查询中看到的那样,我写了 posts.hubId 而不是 posts.hubid 正如错误所说。 The hint is exactly how i have writeen my query.提示正是我如何写我的查询。 It seems to me like the query i wrote is not case-sensitive or what is the problem here?在我看来,我写的查询不区分大小写,或者这里有什么问题?

I ran into similar error trying to execute:我在尝试执行时遇到了类似的错误:

sequelize.query("DROP ENUM enum_table_enumName;")

What solved it for me was:为我解决的是:

sequelize.query(
  "DROP ENUM public.\"enum_table_enumName\";", 
  {
    type: sequelize.QueryTypes.DELETE 
  }
);

Note: public is the schema name (default schema).注意: public是架构名称(默认架构)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM