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

Changed sequelize.or behavior #3107

Closed
BridgeAR opened this Issue Feb 11, 2015 · 4 comments

Comments

3 participants
@BridgeAR
Contributor

BridgeAR commented Feb 11, 2015

The refactored where logic also changed the behavior of sequelize.and and sequelize.or.

I used the following statement:

sequelize.or({
    roleName: rolesNew
}, {
    roleName: 'CLIENT',
    type: clientType
})

It was translated to
roleName: rolesNew OR roleName: 'CLIENT' AND type: clientType
after the refactor it's
roleName: rolesNew OR roleName: 'CLIENT' OR type: clientType

Of course the following works as expected:

sequelize.or({
    roleName: rolesNew
}, sequelize.and({
    roleName: 'CLIENT'
}, {
    type: clientType
}))

And this works too:

sequelize.or({
    roleName: rolesNew
}, sequelize.and({
    roleName: 'CLIENT',
    type: clientType
}))

When reading the doku it's not really clear if the new behavior is the more favored one or not.

@janmeier

This comment has been minimized.

Member

janmeier commented Feb 11, 2015

That behaviour is definitely not desired

@janmeier janmeier added the bug label Feb 11, 2015

@mickhansen

This comment has been minimized.

Contributor

mickhansen commented Feb 11, 2015

Hmm no that's definitely a regression, strange it wasn't caught by a test.

@mickhansen

This comment has been minimized.

Contributor

mickhansen commented Feb 12, 2015

It's a bit tricky, since we support stuff like:

$or: {
  email: 'heyo',
  name: 'heyo'
}

Now, which results in an or.
So i suppose the rule is that if $or is an array then its OR between the arrays but AND inside.

@mickhansen

This comment has been minimized.

Contributor

mickhansen commented Feb 12, 2015

Fixed in sequelize@2.0.2

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