title: How get values from postgres JSONB column?
body: <p>I have PostgreSQL 10.5 database with Rails 5 application.</p>
  
  <p>My model:</p>
  
  <pre><code># == Schema Information
  #
  # Table name: property_keys
  #
  #  id         :integer          not null, primary key
  #  name       :string
  #  created_at :datetime         not null
  #  updated_at :datetime         not null
  #  i18n_name  :jsonb
  #
  
  class PropertyKey &lt; ApplicationRecord
    # Fields
    store :i18n_name, accessors: I18n.available_locales, coder: JSON
  end
  </code></pre>
  
  <p>My migration:</p>
  
  <pre><code>class LocalizeProperties &lt; ActiveRecord::Migration[5.2]
    def up
      add_column :property_keys, :i18n_name, :jsonb
  
      PropertyKey.all.each do |property_key|
        [:en, :de, :ru].each do |locale_key|
          property_key.i18n_name[locale_key] = property_key.name
        end
  
        property_key.save!
      end
    end
  
    def down
      remove_column :property_keys, :i18n_name
    end
  end
  </code></pre>
  
  <p>Table name: <code>property_keys</code>. List of fields:</p>
  
  <ul>
  <li>id: bigint</li>
  <li>i18n_name: jsonb</li>
  </ul>
  
  <p>Here is a request for all data:</p>
  
  <p><a href="https://i.stack.imgur.com/TCr74.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TCr74.png" alt="enter image description here"></a></p>
  
  <p>I want to get all english names (values of <code>"en"</code> key inside <code>i18n_name</code> column).</p>
  
  <p>Here is a request:</p>
  
  <pre><code>SELECT
      id,
      i18n_name,
      i18n_name-&gt;'en' AS en
  FROM property_keys;
  </code></pre>
  
  <p>And it returns nothing.</p>
  
  <p>But theoretically should return the data with filled "en" column.</p>
  
  <p>Here is a screenshot:</p>
  
  <p><a href="https://i.stack.imgur.com/dRsBB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dRsBB.png" alt="enter image description here"></a></p>
  
  <p>Also I tried query with <code>-&gt;&gt;</code> and it did not work:</p>
  
  <p><a href="https://i.stack.imgur.com/9NRfQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9NRfQ.png" alt="enter image description here"></a></p>
  
  <p>How should I change my request and which <a href="https://www.postgresql.org/docs/9.6/static/functions-json.html" rel="nofollow noreferrer">PostgreSQL operators</a> should I use to make it works?</p>
  
  <p>Checked length of JSONB columns:</p>
  
  <p><a href="https://i.stack.imgur.com/27uJa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/27uJa.png" alt="enter image description here"></a></p>