Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include.where and Sequelize.or() #1383

Closed
nichdiekuh opened this issue Feb 12, 2014 · 5 comments
Closed

include.where and Sequelize.or() #1383

nichdiekuh opened this issue Feb 12, 2014 · 5 comments

Comments

@nichdiekuh
Copy link

Hello,

I've upgraded my install to sequelize@2.0.0-dev5 and was crossing my fingers for the new sequelize.or() feature to work. Unfortunately it doesn't in my case:

    return Parameter.findAll({where :
        Sequelize.and(
            {key :key}
        )
        ,include:[
            {
               model : Project,
                where : Sequelize.or({'id' : project_id},{'id' : null})
            }
        ]});

Results in:

{ [Error: ER_BAD_FIELD_ERROR: Unknown column 'Projects.args' in 'on clause']
  code: 'ER_BAD_FIELD_ERROR',
  errno: 1054,
  sqlState: '42S22',
  index: 0,
  sql: 'SELECT `Parameters`.*, `Projects`.`id` AS `Projects.id`, `Projects`.`name` AS `Projects.name`, `Projects`.`url` AS `Projects.url`, `Projects`.`api_key` AS `Projects.api_key`, `Projects`.`created_at` AS `Projects.created_at`, `Projects`.`customer_id` AS `Projects.customer_id`, `Projects.ParametersProject`.`project_id` AS `Projects.ParametersProject.project_id`, `Projects.ParametersProject`.`parameter_id` AS `Projects.ParametersProject.parameter_id` FROM `Parameters` INNER JOIN `ParametersProjects` AS `Projects.ParametersProject` ON `Parameters`.`id` = `Projects.ParametersProject`.`parameter_id` INNER JOIN `Projects` AS `Projects` ON `Projects`.`id` = `Projects.ParametersProject`.`project_id` AND `Projects`.`args` IN (`id` = \'1\',`id` = NULL) WHERE (`Parameters`.`key`=\'qmail\');' }

AND Projects.args IN (id = \'1\',id = NULL)

@mickhansen
Copy link
Contributor

1722848

Hmm for some reason the commit is not in the 2.0dev5 tag. Can you check if it works for you on the 2.0.0 branch? If it does i'll do a new release.

@nichdiekuh
Copy link
Author

Downloaded the 2.0 zipfile, copied the files over to my node_modules dir, and...

 AND (`Projects`.`id`='1' OR `Projects`.`id` IS NULL)

...it works! Yay! :)

@mickhansen
Copy link
Contributor

Alright i'll do a release later today

@mickhansen
Copy link
Contributor

I just pushed a dev6 release.

@nichdiekuh
Copy link
Author

Thank you Mick! That was astonishingly quick!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants