Skip to content

add jsonb to fields mapping #3824

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

Merged
merged 1 commit into from
May 5, 2025
Merged

Conversation

manuelmeurer
Copy link
Contributor

Description

JSONB fields should be displayed as code, just like JSON fields.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Manual review steps

Use discover_columns with a model that has a JSONB column. Without this PR, the column is not displayed, with this PR it is.

Happy to add tests if necessary.
Also, defining the FIELDS_MAPPING const could be cleaned up a bit, since many fields have the same value, e.g.:

FIELDS_MAPPING = {
  belongs_to: %i[references belongs_to],
  boolean:    %i[boolean],
  code:       %i[json jsonb],
  date_time:  %i[datetime timestamp time],
  date:       %i[date],
  id:         %i[primary_key],
  number:     %i[integer float decimal binary],
  text:       %i[string],
  textarea:   %i[text]
}.each_with_object({}) do |(key, value), hash|
  value.each {
    hash[_1] = {
      field: key.to_s
    }
  }
end.freeze

Copy link

Code Climate has analyzed commit 6f9b41a and detected 0 issues on this pull request.

View more on Code Climate.

Copy link
Contributor

@Paul-Bob Paul-Bob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this contribution @manuelmeurer!

@Paul-Bob Paul-Bob added the Enhancement Not necessarily a feature, but something has improved label May 5, 2025
@Paul-Bob Paul-Bob merged commit 15e2637 into avo-hq:main May 5, 2025
20 of 21 checks passed
@manuelmeurer manuelmeurer deleted the jsonb_fields_mapping branch May 5, 2025 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Not necessarily a feature, but something has improved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants