question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Data Tree Export Not Returning Results

See original GitHub issue

Summary

A valid query that should return results will not return results when “sfdx force:data:tree:export” is called with a --query flag

Steps To Reproduce:

  1. Create a .soql file with a query that is filtering on the Id field. My example below: SELECT Name FROM Product2 WHERE Id IN ( '01t1X000005P61TQAS', '01t1X0000062jnyQAA', '01t0J00000F4ItSQAV', '01t1X000005P6vXQAS', '01t5I000000AS28QAG', '01t1X000005P7HdQAK', '01t1X0000062uXeQAI' )
  2. Use the sfdx force:data:tree:export command with the query flag. My example below: sfdx force:data:tree:export --query scripts/soql/try2.soql --prefix omnichannelBundle --outputdir data/omnichannelBundle --plan -u WP_nDev --json

Expected result

Query should have returned results (That exact query copy pasted into other tools will return results)

Actual result

Query returned zero results

Additional information

This is only happening when I filter on the Id field trying to match it with the list of Ids. If I use the list of Ids to exclude from the results then it will return some results. I also tried it with a different text field and it worked fine. Examples below:

This Works (notice the “NOT IN”)

SELECT Name FROM Product2 WHERE Id NOT IN ( '01t1X000005P61TQAS', '01t1X0000062jnyQAA', '01t0J00000F4ItSQAV', '01t1X000005P6vXQAS', '01t5I000000AS28QAG', '01t1X000005P7HdQAK', '01t1X0000062uXeQAI' )

This Works (changed to Name field)

SELECT Name FROM Product2 WHERE Name IN ( 'product_1', 'product_2', 'product_3', 'product_4' )

SFDX CLI Version(to find the version of the CLI engine run sfdx --version): sfdx-cli/7.84.2-a2868a68d5 win32-x64 node-v12.18.3

SFDX plugin Version(to find the version of the CLI plugin run sfdx plugins --core):

@oclif/plugin-autocomplete 0.1.5 (core)
@oclif/plugin-commands 1.3.0 (core)
@oclif/plugin-help 3.2.1 (core)
@oclif/plugin-not-found 1.2.4 (core)
@oclif/plugin-plugins 1.9.5 (core)
@oclif/plugin-update 1.3.10 (core)
@oclif/plugin-warn-if-update-available 1.7.0 (core)
@oclif/plugin-which 1.0.3 (core)
@salesforce/sfdx-trust 3.6.0 (core)
alias 1.1.5 (core)
analytics 1.12.1 (core)
auth 1.4.6 (core)
config 1.2.3 (core)
generator 1.1.3 (core)
salesforcedx 50.13.3 (core)
├─ user 1.0.5 (core)
├─ schema 1.0.3 (core)
├─ limits 1.0.2 (core)
├─ templates 50.4.0 (core)
├─ salesforce-alm 50.13.1 (core)
├─ @salesforce/sfdx-plugin-lwc-test 0.1.7 (core)
├─ custom-metadata 1.0.11 (core)
└─ apex 0.1.4 (core)
sfdx-cli 7.84.2 (core)

OS and version: OS Name: Microsoft Windows 10 Enterprise OS Version: 10.0.17763 Build 17763

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
WillieRuemmelecommented, Jan 29, 2021

Wow, great detective work. I’ll take a look and see why that’s happening. That’s one of our new OSS repos, you can see where/why it’s doing it here https://github.com/salesforcecli/data/blob/0ac477e3dcad5c4bf61f4e85b131b05c37d6af37/packages/plugin-data/src/api/data/tree/exportApi.ts#L118 I’ll fix it. just pretty cool to see!

0reactions
justin-lyoncommented, Jun 9, 2022

Getting the same error still.

sfdx-cli/7.154.0 darwin-arm64 node-v18.1.0

@oclif/plugin-autocomplete 0.3.0 (core)
@oclif/plugin-commands 1.3.0 (core)
@oclif/plugin-help 3.3.1 (core)
@oclif/plugin-not-found 1.2.6 (core)
@oclif/plugin-plugins 1.10.11 (core)
@oclif/plugin-update 1.5.0 (core)
@oclif/plugin-warn-if-update-available 1.7.3 (core)
@oclif/plugin-which 1.0.4 (core)
@salesforce/sfdx-plugin-lwc-test 0.1.7 (core)
alias 2.0.1 (core)
apex 0.13.0 (core)
auth 2.0.3 (core)
community 2.0.0 (core)
config 1.4.11 (core)
custom-metadata 1.1.0 (core)
data 2.0.3
generator 2.0.1 (core)
info 2.0.1 (core)
limits 2.0.1 (core)
org 1.13.2 (core)
salesforce-alm 54.4.0 (core)
schema 2.1.1 (core)
sfdx-cli 7.154.0 (core)
signups 1.1.2 (core)
source 1.10.2 (core)
telemetry 2.0.0 (core)
templates 54.8.0 (core)
trust 2.0.1 (core)
user 2.0.2 (core)
-- scripts/soql/testing.sql
SELECT Id
FROM Account
WHERE Id = '0015f000003sTipAAE'
$ sfdx force:data:tree:export -q scripts/soql/testing.sql
Query returned no results
--------------------------------------------------------------------------------
$ sfdx force:data:soql:query --json -q "$(cat scripts/soql/testing.sql)"
{
  "status": 0,
  "result": {
    "totalSize": 1,
    "done": true,
    "records": [
      {
        "attributes": {
          "type": "Account",
          "url": "/services/data/v54.0/sobjects/Account/0015f000003sTipAAE"
        },
        "Id": "0015f000003sTipAAE"
      }
    ]
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

DX CLI force:data:tree:export Query returned no results
I've had a look at reproducing this. I got the same result when the data:tree:export included any specific ID's in the where clause....
Read more >
Export to CSV - APOC Extended Documentation - Neo4j
If we don't want to export to a file, we can stream results back in the data column instead by passing a file...
Read more >
data Commands | Salesforce CLI Command Reference
Exports data from an org into sObject tree format for use with the force:data:tree:import command. The query for export can return a maximum...
Read more >
How to Export MongoDB to CSV, JSON, SQL & BSON ...
A step-by-step guide on how to export MongoDB to CSV, JSON BSON/mongodump, SQL, and another collection using Studio 3T's Export Wizard.
Read more >
WONDER Data Export Help
In addition to the query results, the WONDER export files contain a summary of ... No endorsement or preference is intended for use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found