fix: human output no longer displaying undefined#307
Conversation
@W-11216045@ fixed case for subquery data displaying undefined fixed case where subquery returns more than one row
| (formattedColumns[field] = { | ||
| header: field.toUpperCase(), | ||
| get: (row): string => get(row, field) as string, | ||
| get: (row): string => { |
There was a problem hiding this comment.
Modified the get to first check if the field, as given, can be referenced directly, This solves case where property has a name like foo.bar. If cannot be directly referenced then delegate to get
| const childRecords = getArray(childO, 'records', []); | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| childRecords.forEach((record: unknown) => { | ||
| childRecords.forEach((record: unknown, index) => { |
There was a problem hiding this comment.
There can be more than one child record from a subquery, Account record can have more than one contact associated to it. For subquery records 2-n a synthetic record needs to be added to the results to produce output like
force:data:soql:query -u myalias -q Select name, (Select FirstName, LastName from Contacts) from Account
NAME CONTACTS.FIRSTNAME CONTACTS.LASTNAME
─────────────────────────────── ────────────────── ─────────────────
Test
Sample Account for Entitlements Peter Hale
null Test
Total number of records retrieved: 2.
There was a problem hiding this comment.
can we add a NUT to cover this case?
| value: value ? value : chalk.bold('null'), | ||
| }); | ||
| if (!index) { | ||
| Reflect.defineProperty(result as Record<string, unknown>, `${child.toString()}.${key}`, { |
There was a problem hiding this comment.
Add subquery data to first query record
| value: value ? value : chalk.bold('null'), | ||
| }); | ||
| } else { | ||
| Reflect.defineProperty(newResult, `${child.toString()}.${key}`, { |
There was a problem hiding this comment.
add subquery data to subquery records 2-n
| }); | ||
| } | ||
| newResults.push(result); | ||
| newResults.push(result, ...subResults); |
There was a problem hiding this comment.
Push parent and additional subquery records into result.
|
QA: in the org, create an Account original query printed |
What does this PR do?
fixed case for subquery data displaying undefined
fixed case where subquery returns more than one row
What issues does this PR fix or reference?
@W-11216045@