Show index operator classes in annotations - #382
Open
kamipo wants to merge 1 commit into
Open
Conversation
PostgreSQL indexes can specify a per column operator class (`opclass:`), but the index annotation dropped it entirely, so an index like ```ruby t.index ["name"], using: :gist, opclass: :gist_trgm_ops ``` was annotated as `(name) USING gist`, losing the information that distinguishes it from a plain gist index. Operator classes are per column, so they are now rendered next to the column, in the same order that ActiveRecord generates the index SQL in (column, opclass, order): ``` # index_organizations_on_name_trgm (name gist_trgm_ops) USING gist ``` `IndexDefinition` condenses per column options into a single value when every column shares the same one, so `opclasses` (and `orders`) can be either a Hash keyed by column or a bare value. Both are handled now, which also fixes ordered indexes losing their order when every column shares it: `t.index [:a, :b], order: :desc` was annotated as `(a,b)` and is now annotated as `(a DESC,b DESC)`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PostgreSQL indexes can specify a per column operator class (
opclass:), but the index annotation dropped it entirely, so an index likewas annotated as
(name) USING gist, losing the information that distinguishes it from a plain gist index.Operator classes are per column, so they are now rendered next to the column, in the same order that ActiveRecord generates the index SQL in (column, opclass, order):
IndexDefinitioncondenses per column options into a single value when every column shares the same one, soopclasses(andorders) can be either a Hash keyed by column or a bare value. Both are handled now, which also fixes ordered indexes losing their order when every column shares it:t.index [:a, :b], order: :descwas annotated as(a,b)and is now annotated as(a DESC,b DESC).