Skip to content

Multi-line column comments break annotated comment block #866

Open
@mroach

Description

@mroach

Multi-line column comments are allowed. For example:

t.boolean :handled, null: false, comment: <<~EOF
  If the event instance was handled in accordance with the schedules.event_{type,data}.
  For example, if a Sidekiq job were enqueued, it's considered handled.
EOF
t.jsonb :handler_data, null: true, comment: "Any data to identify the handling, e.g Sidekiq job ID"

When annotating the models:

  1. The lines after the first are not commented-out
  2. The table of fields becomes very wide to the point where it's not usable.
# Table name: schedule_instances
#
#  id                                                                                                                                                                    :bigint           not null, primary key
#  handled(If the event instance was handled in accordance with the schedules.event_{type,data}.
For example, if a Sidekiq job were enqueued, it's considered handled.
) :boolean          default(FALSE), not null
#  handler_data(Any data to identify the handling, e.g Sidekiq job ID)                                                                                                   :jsonb

Possible changes

  1. Figure out the table column width by the longest line e.g. column_name_with_comment.lines.map(&:length).max
  2. Comment-out all lines

Another option may be for multi-line comments, long comments, or perhaps all comments, it might be nice to just put them on a new line and indent it. For example:

# Table name: schedule_instances
#
# id                    :bigint    not null, primary key
# handled               :boolean   default(FALSE), not null
#   If the event instance was handled in accordance with the schedules.event_{type,data}.
#   For example, if a Sidekiq job were enqueued, it's considered handled.
# handler_data          :jsonb
#   Any data to identify the handling, e.g Sidekiq job ID

Commands

  1. Create a multi-line comment on a column
  2. Annotate models

Version

  • annotate version: 3.1.1
  • rails version 6.1
  • ruby version 2.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions