Query is using model property names instead of column names

On one of the Leads collection properties, that are used for search criteria in filters and segments are using model names, not column names. Hence, queries end up being wrong, referencing columns by the missing name

Segment definition:

underscored is set to true on model definition:

Leads.init(...
        isLocked: {
            type: DataTypes.BOOLEAN,
        },
...
    }, {
        tableName: 'leads',
        modelName: 'leads',
        underscored: true,
...
    });

Failure Logs

sql: ... WHERE ... "leads"."isLocked" = false ...

Context

  • Package Version: 7.5.0
  • Express Version: 4.16.3
  • Sequelize Version: 6.6.2
  • Database Dialect: postgresql
  • Database Version: 12
  • Project Name: Leadtime App

Hi @Vasilii,

Is the issue happening only on segment filters? Or basic filters too? Also is the isLocked field correctly retrieved on your records when displayed?

In order to reproduce can I have the original column name of the isLocked field?

Thank you :slight_smile:

Hi @anon37102731! It happens with filters too with fields named in the same snake case.

The column is called is_locked. The same applies to isSystemBlacklist property and is_system_blacklist column.

Here’s the abstract from query, that is failing (column alias is used as column name):

SELECT
...
"leads"."is_locked" AS "isLocked"
...
WHERE ... "leads"."isLocked" = false ...

Hi @Vasilii,

I tried reproducing your issue, but unsuccessfully.

I created a column content_text in my comment table in my database and when I try to filter I can see in my query "comment"."content_text" LIKE '%A%'.
I tried as well to create a segment with where condition on my underscored column, and it works as well.

Do you have any custom code that would affect the request sent? Any specific changes to the model or some custom code in the route?

Also do you have any other underscored fields that are working?

Hi, @anon90145840

Thanks, the route is customized and own properties of the model were not mapped to the corresponding column names.