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

Unusual Query and File Export Behavior #104

Open
unclejieves opened this issue Feb 11, 2021 · 4 comments
Open

Unusual Query and File Export Behavior #104

unclejieves opened this issue Feb 11, 2021 · 4 comments

Comments

@unclejieves
Copy link

I am querying Product2 records which can be hierarchical i.e. Product2 record may have a parent which is a lookup to another product2 record. Not all Product2 records have a parent.

When I query all records( 6k+), which would be inclusive of records with and without a parent, the parent lookup I specify in the query, tk_base_product__r.Name, only shows as tk_base_product__r in the column heading. The results set also does not sort properly when sorting on the parent lookup. Even when i specify DESC it will show records w/o a parent first.

Screen Shot 2021-02-11 at 7 13 51 AM

Even more strange; When I export to CSV it shows the data structure in the relationship field instead of the value of the field i'm specifying.

Screen Shot 2021-02-11 at 7 14 54 AM

However, if I only query a small dataset the column heading and values are as expected in the query and resulting file. Sorting on the parent field still doesn't work though.

Screen Shot 2021-02-11 at 7 16 45 AM

Screen Shot 2021-02-11 at 7 17 22 AM

SOQLx version is 3.4
MacOs 11.1 w/M1 chip

@superfell
Copy link
Owner

On your first point about ordering, you need to use NULLS LAST to have the NULLs ordered to the bottom of the results. see https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_orderby.htm#!

On the column headers issue, the headers are calculated from the data seen in the rows of the query result, if there's no name field populated in those rows then it won't appear as a header. There's no API to have sfdc describe what the columns of the query are, so the only ways to determine the columns is from looking at the actual data returned, or by parsing the soql query itself

@unclejieves
Copy link
Author

unclejieves commented Feb 11, 2021 via email

@superfell
Copy link
Owner

It's resolved from the first set of rows returned by the query API. So all the results you see after clicking Query, but not any of the rows that appear when you subsequently click Query More. (or use the export all rows option in the save dialog) Using NULLS LAST should work as a work around. I'll have to look into having it recheck the column headers after a query more.

@unclejieves
Copy link
Author

unclejieves commented Feb 11, 2021 via email

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