<p></p>
<p dir="auto">Postgres has a weird feature for its indexes where you specify an "opclass" on the fields of the index definition.  SQL::Translator currently doesn't have a place to store this information, in addition to not being able to round-trip for it.</p>
<p dir="auto">Here's an example from <a href="https://www.postgresql.org/docs/current/pgtrgm.html" rel="nofollow">the trigram module</a> :</p>
<p dir="auto">CREATE INDEX trgm_idx ON test_trgm USING GIN (t gin_trgm_ops);</p>
<p dir="auto">I now have two projects using trigram indexes, so the itch to fix it is growing.  I discovered that the DDL generator already has a special case to not quote field names with parentheses in them, so I was able to work around the problem for generating DDL with:</p>
<p dir="auto">-&gt;add_index({<br>
name =&gt; 'trgm_idx',<br>
fields =&gt; [ '(t) gin_trgm_ops' ],<br>
options =&gt; { using =&gt; "GIN" }<br>
})</p>
<p dir="auto">because Postgres allows arbitrary parentheses around the field name.</p>
<p dir="auto">It seems a bit hacky.  In most other places of DBIC when we want literal SQL we can use a scalar ref.  Would that be the right thing to do here?</p>
<p dir="auto">The next question is how to round-trip this.  If I add Postgres Parser support for detecting trigram indices, should I construct index objects like above? (with the parentheses around the column name) or should there be a new scalar-ref feature first and then use that?   On the same topic, I don't see a good way to put the "ASC" or "DESC" flags on the fields either, such as used in</p>
<p dir="auto">CREATE INDEX IF NOT EXISTS x ON y (a DESC, b DESC, c ASC);</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br />Reply to this email directly, <a href="https://github.com/dbsrgits/sql-translator/issues/154">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AACJ4AXIDNCPXS37DIAEMGLWOPI5PANCNFSM6AAAAAATGJMEKA">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AACJ4ATIXZG2HQQOMBXD5UTWOPI5PA5CNFSM6AAAAAATGJMEKCWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHFTVVR7E.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span>&lt;dbsrgits/sql-translator/issues/154</span><span>@</span><span>github</span><span>.</span><span>com&gt;</span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/dbsrgits/sql-translator/issues/154",
"url": "https://github.com/dbsrgits/sql-translator/issues/154",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>