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

Viewed 77

I get an error when running this query with 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. 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?

1 Answers

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).

Related