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

fix: output zero when displaying human results #470

Merged

Conversation

leostewart
Copy link
Contributor

@leostewart leostewart commented Jan 22, 2023

What does this PR do?

Outputs 0 instead of an empty string (regular or aggregate queries) or null (subqueries) in human result format.

What issues does this PR fix or reference?

Attempts to fix forcedotcom/cli#1892

Notes

I didn't add additional tests as it might not be justified, but let me know otherwise.

@leostewart leostewart marked this pull request as ready for review January 22, 2023 11:42
@WillieRuemmele
Copy link
Contributor

Hi @leostewart thanks for the contribution - sorry we missed it until now. Could you add a unit test verifying that a 0 is printed to make sure this won't break again in the future?

@leostewart
Copy link
Contributor Author

Hi @WillieRuemmele, I've added a few unit tests for the mentioned scenarios. As this is a bit of an edge case, I wasn't sure how best to incorporate them into the existing tests, so feel free to make suggestions/changes.

@WillieRuemmele
Copy link
Contributor

QA Notes

setup:
sfdx data record create -s Opportunity -v "Name=testOpportunity StageName=Prospecting CloseDate=2023-12-31 Amount=0"


✅ : displaying 0

 ➜  sfdx data query -q "SELECT Name, Amount FROM Opportunity WHERE Name='testOpportunity'"
 NAME            AMOUNT 
 ─────────────── ────── 
 testOpportunity 0 

vs

 ➜  sfdx data query -q "SELECT Name, Amount FROM Opportunity WHERE Name='testOpportunity'"
 NAME            AMOUNT 
 ─────────────── ────── 
 testOpportunity        
Total number of records retrieved: 1.

✅ : UTs pass
✅ : NUTs pass
✅ : 0 in csv
✅ : null in csv
✅ : null in human
🏆 : fixes another bug with false
before:

 ➜  sfdx data query -q "SELECT Name, Amount,HasOverdueTask,Description,Id FROM Opportunity WHERE Name='testOpportunity'"       
 NAME            AMOUNT HASOVERDUETASK DESCRIPTION ID                 
 ─────────────── ────── ────────────── ─────────── ────────────────── 
 testOpportunity                       null        006DR00000HqjUGYAZ 

after:

 ➜  sfdx data query -q "SELECT Name, Amount,HasOverdueTask,Description,Id FROM Opportunity WHERE Name='testOpportunity'" 
 NAME            AMOUNT HASOVERDUETASK DESCRIPTION ID                 
 ─────────────── ────── ────────────── ─────────── ────────────────── 
 testOpportunity 0      false          null        006DR00000HqjUGYAZ 

@WillieRuemmele WillieRuemmele merged commit 3563d7d into salesforcecli:main Feb 6, 2023
@WillieRuemmele
Copy link
Contributor

Thank you so much @leostewart 🎉 🏆

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

Successfully merging this pull request may close these issues.

data query does not show 0 in human result format
2 participants