<p dir="auto"><strong>Migrated issue, originally created by Andrey Semenov</strong></p>
<p dir="auto">I need to construct a query like</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="SELECT (jsonb_each('{&quot;a&quot;: 1, &quot;b&quot;: 2}')).key
"><pre class="notranslate"><code class="notranslate">SELECT (jsonb_each('{"a": 1, "b": 2}')).key

</code></pre></div>
<p dir="auto"><code class="notranslate">jsonb_each()</code> returns a RECORD type which in turn has it's own fields named <code class="notranslate">key</code> and <code class="notranslate">value</code>. Yes, in PostgreSQL it MUST be also wrapped into braces, because of extraction and executing precedence (or it will try to select a <code class="notranslate">key</code> column from the <code class="notranslate">jsonb_each()</code> column - that leads to SQL engine error raised). It's not obvious how to query those fields while constructing a query (or make a dot-notated reference to a custom sub-field when this capability is provided by an engine).</p>
<p dir="auto">Also, dialects.util.dottedgetter does not work with func.* (returns None if called against)</p>
<p dir="auto"><strong>Migrated issue, originally created by Michael Bayer (<a href="https://github.com/zzzeek">@zzzeek</a>)</strong></p>
<p dir="auto">this would expand upon _load_enums() in postgresql/base.py, so that any kind of custom type is recognized during reflection.  We'd likely have to create some kind of "ad-hoc" type that is declared like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from sqlalchemy.dialects.postgresql import TYPE
Column(&quot;mycolumn&quot;, TYPE(&quot;MY_CUSTOM_TYPE&quot;))"><pre class="notranslate"><code class="notranslate">from sqlalchemy.dialects.postgresql import TYPE
Column("mycolumn", TYPE("MY_CUSTOM_TYPE"))
</code></pre></div>