Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

include association not honoring paranoid flag #1192

Closed
maxstudener opened this Issue Jan 3, 2014 · 4 comments

Comments

Projects
None yet
3 participants

Chat.findAll({include: [db.User], where: {id: chatIds}})

SELECT
    `Chats`.*,
    `Users`.`email`         AS `Users.email`,
    `Users`.`lastRequestAt` AS `Users.lastRequestAt`,
    `Users`.`online`        AS `Users.online`,
    `Users`.`provider`      AS `Users.provider`,
    `Users`.`uid`           AS `Users.uid`,
    `Users`.`name`          AS `Users.name`,
    `Users`.`admin`         AS `Users.admin`,
    `Users`.`deletedAt`     AS `Users.deletedAt`,
    `Users`.`id`            AS `Users.id`,
    `Users`.`createdAt`     AS `Users.createdAt`,
    `Users`.`updatedAt`     AS `Users.updatedAt`
FROM
    `Chats`
LEFT OUTER JOIN
    `ChatsUsers`
ON
    `Chats`.`id` = `ChatsUsers`.`ChatId`
LEFT OUTER JOIN
    `Users` AS `Users`
ON
    `Users`.`id` = `ChatsUsers`.`UserId`
WHERE
    `Chats`.`id` IN (2,4,5,7)
AND `Chats`.`deletedAt` IS NULL;
Owner

mickhansen commented Jan 3, 2014

No i imagine it's not. I'll add it to my list. But it'll get done a lot faster if you can whip me up a self-contained unit test.

@mickhansen mickhansen was assigned Jan 3, 2014

mryangyu commented Apr 1, 2014

I added this code to dao-factory paranoidClause function at line 1298 and seems to work:

     if (options.include) {
        var _this = this;
        options.include.forEach(function(include) {
          paranoidClause.call(_this, include)
        });
      }

shall I do a pull request?

Owner

mickhansen commented Apr 2, 2014

@mryangyu need to handle nested includes aswell - it's probably better to put this in DAOFactory.includeValidatedElement. If you can provide a PR with tests covering both includes and nested includes it would be awesome!

Owner

mickhansen commented Apr 29, 2014

Issue fixed in #1678 by @cusspvz

@mickhansen mickhansen closed this Apr 29, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment