title: How to query for empty array in JSONB?
body: <p>Consider this example:</p>
  
  <pre><code>postgres=# CREATE TABLE emptyarray (fields jsonb);                                                                                                                            
  CREATE TABLE                                                                                                                                                                  
  postgres=# INSERT INTO emptyarray VALUES ('{"key":["a","b"]}');                                                                                                               
  INSERT 0 1                                                                                                                                                                    
  postgres=# INSERT INTO emptyarray VALUES ('{"key":[]}');                                                                                                                      
  INSERT 0 1                                                                                                                                                                    
  postgres=# SELECT * from emptyarray where Fields@&gt;'{"key":["b"]}';                                                                                                            
         fields                                                                                                                                                                 
  ---------------------                                                                                                                                                         
   {"key": ["a", "b"]}                                                                                                                                                          
  (1 row)                                                                                                                                                                       
  
  postgres=# SELECT * from emptyarray where Fields@&gt;'{"key":[]}';                                                                                                               
         fields                                                                                                                                                                 
  ---------------------                                                                                                                                                         
   {"key": ["a", "b"]}                                                                                                                                                          
   {"key": []}                                                                                                                                                                  
  (2 rows)
  </code></pre>
  
  <p>In the second query I expected only one rows in the results (the one record with empty array). But as you can see there are two rows in the result. How do I query for a empty array using <code>@&gt;</code> syntax?</p>
  
  <p>I am using PostgreSQL 9.6</p>