Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

How do I get all the empty records for a jsonb column with Active Record ?

share|improve this question
    
Are you looking for all rows where the jsonb column is null? Or, are you looking for all rows where the jsonb column is an empty object '{}'? Some example code/sql would help here. – mrwillihog Jun 8 at 14:24
    
I am looking for all the rows where the jsonb column is an empty object '{}' . I actually tried Active Record query interface Model.where.not(my_column: {}) – Shani 2 days ago
    
Have you tried Model.where("my_column = '{}'") – mrwillihog 2 days ago
    
Thanks that works – Shani 2 days ago
    
I'll add it as an answer then. – mrwillihog 2 days ago
up vote 1 down vote accepted

You can query for empty objects in a JSONB column using the following syntax:

Model.where("column = '{}'")
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.