Skip to content

fix(querybuilder): Use correct formatting in QueryBuilder#7512

Merged
grantfitzsimmons merged 4 commits intomainfrom
issue-7510
Oct 30, 2025
Merged

fix(querybuilder): Use correct formatting in QueryBuilder#7512
grantfitzsimmons merged 4 commits intomainfrom
issue-7510

Conversation

@melton-jason
Copy link
Contributor

@melton-jason melton-jason commented Oct 24, 2025

Fixes #7510
See related #7080

The underlying problem was due to how the default formatter props for query execution were being interpreted and constructed, as well as the value of the format_expr being interpreted in

Specifically, the problem stemmed from the defined default values of ObjectFormatterProps:

class ObjectFormatterProps(NamedTuple):
format_agent_type: bool = False,
format_picklist: bool = False,
format_types: bool = True,
numeric_catalog_number: bool = True,
# format_expr determines if make_expr should call _fieldformat, like in versions before 7.10.2.
# Batch edit expects it to be false to correctly handle some edge cases.
format_expr: bool = False

Each of the values ending in a comma were being interpreted as one-tuples when it's clear they were meant to be booleans. For illustration, the above was being interpreted as the following:

 class ObjectFormatterProps(NamedTuple): 
     format_agent_type: bool = (False,)
     format_picklist: bool = (False, )
     format_types: bool = (True, )
     numeric_catalog_number: bool = (True, )
     # format_expr determines if make_expr should call _fieldformat, like in versions before 7.10.2. 
     # Batch edit expects it to be false to correctly handle some edge cases. 
     format_expr: bool = False 

This led to issues when the default was used in the execute function in stored_queries/execution.py:

formatter_props=ObjectFormatterProps(),

formatter_props=formatter_props,

Thus there were two issues with the default formatter_props:

  • All non format_expr values in the ObjectFormatterProps was being interpreted incorrectly
  • For normal Queries, the format_expr should by True. The default ObjectFormatterProps has a False format_expr

I think we should evaluate whether or not to change the default format_expr in ObjectFormatterProps to True, especially if the only case for it being False is batch edit.

Checklist

  • Self-review the PR after opening it to make sure the changes look good and
    self-explanatory (or properly documented)
  • Add relevant issue to release milestone
  • Add pr to documentation list
  • Add automated tests
  • Add a reverse migration if a migration is present in the PR

Testing instructions

  • Create a table format that includes a boolean field value (e.g. isPrimary or a yesNo field)
  • See that the preview in the table format editor shows "Yes" or "No" where a value is present
  • Run a query that returns that format
  • See that the appropriate value is not displayed in v7.11.2.1
  • See that the appropriate value is displayed in issue-7510

@melton-jason melton-jason requested review from a team October 24, 2025 21:07
Triggered by f55bd44 on branch refs/heads/issue-7510
Copy link
Collaborator

@emenslin emenslin left a comment

Choose a reason for hiding this comment

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

  • Create a table format that includes a boolean field value (e.g. isPrimary or a yesNo field)
  • See that the preview in the table format editor shows "Yes" or "No" where a value is present
  • Run a query that returns that format
  • See that the appropriate value is not displayed in v7.11.2.1
  • See that the appropriate value is displayed in issue-7510

Looks good, in query results a 1/0 is shown for a boolean field
Screenshot 2025-10-24 170006

I did notice though that if you try to batch edit with the format that includes the boolean field that it looks incorrect. It has the same behavior in main though so I am not sure if this is a problem for this PR or not so I will approve but I can rereview if this is something that needs to be fixed here or write up an issue if this is out of scope for this PR.
Screenshot 2025-10-24 165839

Copy link
Member

@grantfitzsimmons grantfitzsimmons left a comment

Choose a reason for hiding this comment

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

  • Create a table format that includes a boolean field value (e.g. isPrimary or a yesNo field)
  • See that the preview in the table format editor shows "Yes" or "No" where a value is present
  • Run a query that returns that format
  • See that the appropriate value is not displayed in v7.11.2.1
  • See that the appropriate value is displayed in issue-7510

@grantfitzsimmons grantfitzsimmons requested a review from a team October 25, 2025 01:20
Copy link
Contributor

@alesan99 alesan99 left a comment

Choose a reason for hiding this comment

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

  • Create a table format that includes a boolean field value (e.g. isPrimary or a yesNo field)
  • See that the preview in the table format editor shows "Yes" or "No" where a value is present
  • Run a query that returns that format
  • See that the appropriate value is not displayed in v7.11.2.1
  • See that the appropriate value is displayed in issue-7510

before -> now
image
chrome_Kqt6mAg6mZ

Formatters appear as expected now 👍

@grantfitzsimmons grantfitzsimmons merged commit d20570c into main Oct 30, 2025
14 checks passed
@grantfitzsimmons grantfitzsimmons deleted the issue-7510 branch October 30, 2025 21:11
@github-project-automation github-project-automation bot moved this from 📋Back Log to ✅Done in General Tester Board Oct 30, 2025
@grantfitzsimmons
Copy link
Member

CSIRO confirmed this fix is good as well on Asana @melton-jason

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅Done

Development

Successfully merging this pull request may close these issues.

Boolean values do not display when presented in a table format on the front end

5 participants