Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Place column comments at the end of the line (feature suggestion) #164

Open
Adeynack opened this issue Nov 14, 2024 · 4 comments
Open

Place column comments at the end of the line (feature suggestion) #164

Adeynack opened this issue Nov 14, 2024 · 4 comments
Assignees

Comments

@Adeynack
Copy link

Prelude

This feature was implemented by me in annotate_models in those PRs: #988 and #999. Since that other GEM does not seem to be maintained anymore, I am considering a switch to annotaterb but would love that feature to follow.

I volunteer for implementing it, but I prefer to first post this as an issue, in case there is resistance to the idea.

It would be anyways an opt-in and would not change the behavior otherwise. It would also open the door to further formats in the future.

Feature Suggestion

At the moment, when we configure the column comments to be documented, we get them with the name of the column, on the left of the table.

#  type                                                                                                            :enum             not null
#  book_id                                                                                                         :uuid             not null, indexed
#  parent_id(A null parent means it is a root register.)                                                           :uuid             indexed
#  starts_at(Opening date of the register (eg: for accounts, but not for categories).)                             :date
#  expires_at(Optional expiration date of the register (eg: for a credit card).)                                   :date
#  currency_iso_code                                                                                               :string(3)        not null

What is proposed here is to add a new configuration that allow the user to state if they want the comment with the column name (the actual behavior, and would be the default), or at the very end of the table (on the right).

The reason for such a feature is that those comments are extra information, and pushing the whole table further to the right for having them is not ideal. Also, they could potentially be long and it's then better to scroll right to read them comments, than to read their type / nullity / etc.

The proposed configuration key would be position_of_column_comment and could have the following values:

Value Description
with_name (default) The comment appears with next to the name, in parenthesis.
rightmost_column The comment appears in its own column, at the far right of the table.

Example above, configured with rightmost_column:

#  type               :enum             not null
#  book_id            :uuid             not null, indexed   A null parent means it is a root register.
#  parent_id          :uuid             indexed
#  starts_at          :date                                 Opening date of the register (eg: for accounts, but not for categories).
#  expires_at         :date                                 Optional expiration date of the register (eg: for a credit card).
#  currency_iso_code  :string(3)        not null

Contribution

As mentioned in the prelude, I offer to implement this myself, so do not hesitate to assign this to me if there is no objections.

@drwl
Copy link
Owner

drwl commented Nov 15, 2024

Hi, thanks for bringing this up. No objections here. I meant to get around to this after this refactor landed [1] (while unemployed), but then I got a job and haven't had a chance to sit down and get to it. Looking forward to having this as an addition. Please let me know if the refactors that I made do help or not, I'm actually very curious how it feels to make such changes.

[1] 710fec8

@Adeynack
Copy link
Author

Thanks for pointing out this refactor. Will help my understanding of the structure.

@Adeynack
Copy link
Author

@drwl : I am starting work on this. Please assign me to it, just to make it obvious and avoid someone maybe picking it up (if that is how you work on this repository).

@drwl
Copy link
Owner

drwl commented Nov 16, 2024

Sure I can assign you. I haven't had that issue yet where people would duplicate work (a good problem to have), but perfectly fine to make it clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants