Skip to content

fix: correct field access in isFieldSubquery check and fieldMetadataSubquery lookup#1644

Open
Copilot wants to merge 3 commits intomainfrom
copilot/fix-isfieldsubquery-check
Open

fix: correct field access in isFieldSubquery check and fieldMetadataSubquery lookup#1644
Copilot wants to merge 3 commits intomainfrom
copilot/fix-isfieldsubquery-check

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 6, 2026

Two incorrect property accesses in data-table-utils.tsx caused subquery column metadata to be silently dropped.

Changes

  • isFieldSubquery index fix: results.parsedQuery?.[i] was indexing the query object as an array — corrected to results.parsedQuery?.fields?.[i] to match the actual structure used elsewhere in the file.

  • fieldMetadataSubquery two-level lookup: fieldMetadataSubquery?.[field] was using a flat field string against a Record<string, Record<string, Field>> structure — corrected to fieldMetadataSubquery?.[parentField.subquery.relationshipName]?.[field.toLowerCase()] to properly traverse both levels.

// Before
isSubquery: isFieldSubquery(results.parsedQuery?.[i])
fieldMetadata: fieldMetadataSubquery?.[field]

// After
isSubquery: isFieldSubquery(results.parsedQuery?.fields?.[i])
fieldMetadata: fieldMetadataSubquery?.[parentField.subquery.relationshipName]?.[field.toLowerCase()]
Original prompt
Please apply the following diffs and create a pull request.
Once the PR is ready, give it a title based on the messages of the fixes being applied.

[{"message":"The `isFieldSubquery` check is incorrectly checking `results.parsedQuery?.[i]` instead of accessing the fields array. It should be `results.parsedQuery?.fields?.[i]` to match the structure used elsewhere in the code.","fixFiles":[{"filePath":"libs/ui/src/lib/data-table/data-table-utils.tsx","diff":"diff --git a/libs/ui/src/lib/data-table/data-table-utils.tsx b/libs/ui/src/lib/data-table/data-table-utils.tsx\n--- a/libs/ui/src/lib/data-table/data-table-utils.tsx\n+++ b/libs/ui/src/lib/data-table/data-table-utils.tsx\n@@ -169,7 +169,12 @@\n \n   // Base fields\n   const parentColumns: ColumnWithFilter<RowWithKey>[] = getFlattenedFields(results.parsedQuery || {}).map((field, i) =>\n-    getQueryResultColumn({ field, queryColumnsByPath, isSubquery: isFieldSubquery(results.parsedQuery?.[i]), fieldMetadata }),\n+    getQueryResultColumn({\n+      field,\n+      queryColumnsByPath,\n+      isSubquery: isFieldSubquery(results.parsedQuery?.fields?.[i]),\n+      fieldMetadata,\n+    }),\n   );\n \n   // set checkbox as first column\n"}]},{"message":"The `fieldMetadataSubquery` lookup is using `field` (a string) directly, but `fieldMetadataSubquery` is typed as `Record<string, Record<string, Field>>`, which requires two levels of indexing. This should likely be `fieldMetadataSubquery?.[parentField.subquery.relationshipName]?.[field.toLowerCase()]` to properly access the nested structure.","fixFiles":[{"filePath":"libs/ui/src/lib/data-table/data-table-utils.tsx","diff":"diff --git a/libs/ui/src/lib/data-table/data-table-utils.tsx b/libs/ui/src/lib/data-table/data-table-utils.tsx\n--- a/libs/ui/src/lib/data-table/data-table-utils.tsx\n+++ b/libs/ui/src/lib/data-table/data-table-utils.tsx\n@@ -207,7 +207,7 @@\n           queryColumnsByPath,\n           isSubquery: false,\n           allowEdit: false,\n-          fieldMetadata: fieldMetadataSubquery?.[field],\n+          fieldMetadata: fieldMetadataSubquery?.[parentField.subquery.relationshipName]?.[field.toLowerCase()],\n         }),\n       );\n     });\n"}]}]

Copilot AI changed the title [WIP] Fix isFieldSubquery check to access fields array correctly fix: correct field access in isFieldSubquery check and fieldMetadataSubquery lookup Apr 6, 2026
Copilot AI requested a review from paustint April 6, 2026 23:30
@paustint paustint marked this pull request as ready for review April 7, 2026 03:25
Copilot AI review requested due to automatic review settings April 7, 2026 03:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes two incorrect property accesses in the UI data table column-definition logic that could cause subquery metadata/handling to be skipped.

Changes:

  • Corrected isFieldSubquery detection to index into results.parsedQuery.fields rather than the query object.
  • Updated subquery field metadata lookup to traverse the nested Record<string, Record<string, Field>> structure.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 7, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.jsdelivr.net
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@paustint paustint force-pushed the copilot/fix-isfieldsubquery-check branch 2 times, most recently from a1c1e05 to 88af1f5 Compare April 8, 2026 02:57
@paustint paustint requested a review from Copilot April 8, 2026 02:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +173 to +186
// Build a set of subquery relationship names for reliable lookup
// (positional index is unreliable because getFlattenedFields uses flatMap, e.g. TYPEOF expands to multiple entries)
const subqueryRelationshipNames = new Set(
results.parsedQuery?.fields?.filter(isFieldSubquery).map((f) => f.subquery.relationshipName) || [],
);

// Base fields
const parentColumns: ColumnWithFilter<RowWithKey>[] = getFlattenedFields(results.parsedQuery || {}).map((field, i) =>
getQueryResultColumn({ field, queryColumnsByPath, isSubquery: isFieldSubquery(results.parsedQuery?.[i]), fieldMetadata }),
const parentColumns: ColumnWithFilter<RowWithKey>[] = getFlattenedFields(results.parsedQuery || {}).map((field) =>
getQueryResultColumn({
field,
queryColumnsByPath,
isSubquery: subqueryRelationshipNames.has(field),
fieldMetadata,
}),
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

subqueryRelationshipNames is built with relationship names as-is, and the Set.has(field) check is case-sensitive. Elsewhere in the codebase relationship names are compared case-insensitively (e.g., using .toLowerCase()), and Salesforce SOQL/metadata is generally case-insensitive. Consider normalizing both sides (store relationshipName.toLowerCase() in the set and check field.toLowerCase()) so subquery detection doesn’t fail when the query uses different casing.

Copilot uses AI. Check for mistakes.
@paustint paustint force-pushed the copilot/fix-isfieldsubquery-check branch from 88af1f5 to 08c16a8 Compare April 8, 2026 16:00
@paustint paustint requested a review from Copilot April 10, 2026 15:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Successfully merging this pull request may close these issues.

3 participants