title: SQLAlchemy JSON column custom properties
body: <p>In SQLAlchemy JSON columns can contain arbitrary datastructures. To have easier access to some of the deeper elements of the column, I'd like to create custom properties on the column. A simple example can be a column like:</p>
  
  <pre class="lang-py prettyprint-override"><code>class Model(db.Model):
      language = db.Column(postgresql.JSON(), nullable=False,
                           default={"nl": "", "en": ""})
  </code></pre>
  
  <p>Then I'd like to have an property on the <code>language</code> attribute such that we can type <code>entity.language.en</code> and <code>entity.language.nl</code>. I've attempted to create a custom column type:</p>
  
  <pre class="lang-py prettyprint-override"><code>class TranslatedColumn(db.Column):
      def __init__(self, *args, **kwargs):
          super().__init__(postgresql.JSON(), nullable=False,
                           default={"nl": "", "en": ""})
      @hybrid_property
      def en(self):
          return self["en"].astext
      @hybrid_property
      def nl(self):
          return self["nl"].astext
  </code></pre>
  
  <p>Which works when querying the column: <code>db.session.query(Model).filter(Model.language.en == "somestr")...</code>, however when I try to access the column on an entity, <code>entity.language == {"nl": "", "en": ""}</code>, which is a <code>dict</code>.</p>
  
  <p>Is there any way to create a such a structure, based on the JSON columns of SQLAlchemy?</p>