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

Casting JSON fields in where clause #4257

Closed
tmont opened this issue Aug 4, 2015 · 2 comments
Closed

Casting JSON fields in where clause #4257

tmont opened this issue Aug 4, 2015 · 2 comments
Labels
type: feature For issues and PRs. For new features. Never breaking changes.

Comments

@tmont
Copy link
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
Copy link
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 type: feature For issues and PRs. For new features. Never breaking changes. label Aug 5, 2015
@mahnunchik
Copy link

Hi @janmeier @mickhansen how to cast values in JSON?

Related: #11998

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature For issues and PRs. For new features. Never breaking changes.
Projects
None yet
Development

No branches or pull requests

3 participants