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

Casting JSON fields in where clause #4257

Closed
tmont opened this Issue Aug 4, 2015 · 1 comment

Comments

2 participants
@tmont
Contributor

tmont commented Aug 4, 2015

I can't really figure if this is supported or not. I'm basically trying to query by equality on a boolean value inside a JSON object:

MyModel.findAll({
  where: {
    someJsonColumn: {
      someProperty: {
        $eq: true
      }
    }
  }
})

This throws a noperator does not exist: text = boolean error. Basically the query needs a ::boolean cast at the end of it, and I'm not totally sure if that's even possible in Sequelize.

As a workaround, I can just change true to 'true', but I'd rather not do that if I don't have to.

@janmeier

This comment has been minimized.

Member

janmeier commented Aug 5, 2015

I think I talked with @mickhansen about this previously, and we'd really like this to be transparent for the user, so the value is casted automagically.

@janmeier janmeier added the feature label Aug 5, 2015

@janmeier janmeier closed this in fe3e1c5 Aug 31, 2015

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