Skip to content

Model.count() regression in 3.15.0. Attributes are missing in SQL query #5057

@smolyakoff

Description

@smolyakoff

This code used to work in v3.14.2

var Sequelize = require('Sequelize');

var connection = new Sequelize("postgres://postgres:admin@localhost:5432/app_db");

var Download = connection.define('download', {
    id: {type: Sequelize.UUID, primaryKey: true},
    type: {type: Sequelize.INTEGER},
    user: {type: Sequelize.UUID},
    createdAt: {
        field: 'created_at',
        type: Sequelize.DATE
    },
    updatedAt: {
        field: 'updated_at',
        type: Sequelize.DATE
    }
}, {
    underscored: true,
    tableName: 'downloads'
});

Download.count({
    attributes: [
        [Sequelize.literal('date_part(\'month\', "created_at" at TIME ZONE INTERVAL \'+03:00\')'), 'd_month']
    ],
    group: ['d_month']
}).then(function(result) {
    console.log(result);
}).done();

The generated SQL output was:

SELECT date_part('month', "created_at" at TIME ZONE INTERVAL '+03:00') AS "d_month", count(*) AS "count" FROM "downloads" AS "download" GROUP BY "d_month";

In 3.15.0 the same code results in error, generated SQL output doesn't include custom attributes

SELECT count(*) AS "count" FROM "downloads" AS "download" GROUP BY "d_month";

Metadata

Metadata

Assignees

Labels

regressionFor issues and PRs. A bug that does not happen in an earlier version of Sequelize.type: bugDEPRECATED: replace with the "bug" issue type

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions