-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat: beta tree exports/import #810
Conversation
Sm/hierarchies
QA NOTES
QA POST-MERGE UPDATE (export and import)
|
I still have a few things to test. If it is helpful, there is the bash script I am using:
#!/bin/bash
# Create an Account
# - Create a Case related to Account
# - Create a Task related to Case
# - Create an Opportunity related to Account
# - Create a Task related to Opportunity
QUERIES=(
# "SELECT Id, Name, (SELECT Name, Address__c FROM Properties__r), (SELECT FirstName) FROM Broker__c"
# "SELECT Id, Name, (SELECT Id, CaseNumber, (SELECT Id, Subject FROM Tasks) FROM Cases) FROM Account"
# "SELECT Id, Name, (SELECT Id, Name, StageName, CloseDate, (SELECT Id, Subject FROM Tasks) FROM Opportunities), (SELECT Id, CaseNumber, (SELECT Id, Subject FROM Tasks) FROM Cases) FROM Account"
"SELECT Id, Name, (SELECT Id, Name, StageName, CloseDate, (SELECT Id, Subject FROM Tasks) FROM Opportunities), (SELECT Id, Subject, Status, (SELECT Id, Subject FROM Tasks) FROM Cases) FROM Account"
# "SELECT Id, Name, (SELECT Id, Origin, (SELECT Id FROM Tasks), (SELECT Id, ActivityDateTime, DurationInMinutes FROM Events) FROM Cases) FROM Account"
# "SELECT Id, (SELECT Id FROM Tasks), (SELECT Id FROM Events) FROM Case"
# "SELECT Id, Name, Phone, Website, NumberOfEmployees, Industry, (SELECT Lastname, Title, Email FROM Contacts) FROM Account WHERE Name LIKE 'SampleAccount%'"
# "SELECT Id, Name, (SELECT Id, Origin, (SELECT Id FROM Tasks), (SELECT Id, ActivityDateTime, DurationInMinutes FROM Events) FROM Cases) FROM Account"
)
PACKAGE_NAME=$(cat package.json | jq -r '.name')
# if name is not dreamhouse-lwc, then echo warning and exit
if [ "$PACKAGE_NAME" != "dreamhouse-lwc" ]; then
echo "This script should be ran from the root of a Dreamhouse project"
exit 0
fi
DATA_BETA_DIR="/Users/ewillhoit/dev/plugin-data"
DREAMOUSE_DIR=$(pwd)
TIME=$(date +%s)
INDEX=0
for QUERY in "${QUERIES[@]}"
do
TEST_DIR="$DREAMOUSE_DIR/data-export/$TIME/$INDEX"
INDEX=$((INDEX+1))
mkdir -p "$TEST_DIR"
echo "$QUERY" > "$TEST_DIR/query.txt"
echo "Running query: $QUERY"
# echo "SF command"
# sf data tree export -q "$QUERY" -d "$TEST_DIR" --plan --json 2>&1 | tee "$TEST_DIR/export-output.json"
# git -C "$TEST_DIR" init
# git -C "$TEST_DIR" add -A
# git -C "$TEST_DIR" commit -m "sf command" --no-gpg-sign
echo "Beta export command"
# With --plan
$DATA_BETA_DIR/bin/run.js data tree beta export -q "$QUERY" -d "$TEST_DIR" --plan --json 2>&1 | tee "$TEST_DIR/export-output.json"
# Without --plan
# $DATA_BETA_DIR/bin/run.js data tree beta export -q "$QUERY" -d "$TEST_DIR" --json 2>&1 | tee "$TEST_DIR/export-output.json"
# git -C "$TEST_DIR" diff
echo "Beta export command"
# With --plan
JSON=$($DATA_BETA_DIR/bin/run.js data import beta tree --plan "$(ls $TEST_DIR/*-plan.json)" --json)
# Without --plan
# JSON=$($DATA_BETA_DIR/bin/run.js data import beta tree --files "$(ls $TEST_DIR/Account*.json)" --json)
echo $JSON | jq '.'
echo $JSON > "$TEST_DIR/import-output.json"
echo -n "Number or records: "
echo $JSON | jq '.result | length'
done
|
That's the API's limit. The |
Ah, I see that now. That warning message was lost in all the json output |
QA UPDATE
|
@@ -30,7 +30,7 @@ Directory in which to generate the JSON files; default is current directory. | |||
|
|||
- Export records retrieved with the specified SOQL query into a single JSON file in the current directory; the command uses your default org: | |||
|
|||
<%= config.bin %> <%= command.id %> --query "SELECT Id, Name, (SELECT Name, Address__c FROM Properties__r) FROM Broker__c" | |||
<%= config.bin %> <%= command.id %> --query "SELECT Id, Name, (SELECT Name, Address\_\_c FROM Properties\_\_r) FROM Broker\_\_c" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do a quick scan for incorrect formatting like these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a formatter issue, it is escaping the underscores
|
||
# flags.files.summary | ||
|
||
Comma-separated and in-order JSON files that contain the records, in sObject tree format, that you want to insert. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't we been suggesting passing the flag multiple times with arrayWithDeprecation
instead of separated values?
QA UPDATE
|
QA UPDATE
|
Edit the command plan
…lugin-data into sm/soql-5-levels
I am unable to reproduce large record error I was seeing a few days ago. I am now getting past 1536 records (to 3072) and on the next run a get a |
What does this PR do?
Phase 1: Beta
data import beta tree
anddata export beta tree
Breaking changes between existing and beta
import beta
removes its hidden, deprecatedcontent-type
. Only json files are supported. Usage: ~5 per year.import beta
removes the--config-help
flag. The schema stuff is in the command help. Usage: ~1 per week.Other differences
export --plan
writes Object names as the file name. It used to append ans
on the end. So the filename is nowAccount.json
andFoo__c.json
instead ofAccounts.json
and the awfulFoo__cs.json
export beta
no longer writes empty child objects. Previously, you'd see properties with{records: []}
that had no effect on imports.import beta
with--plan
does not care aboutresolveRefs
andsaveRefs
import beta
with--plan
does not care about the order of files in yourplan
file. It'll defer unresolved references until they're resolved.export beta
now handles more than 2 levels of child objects in a query using--plan
(up to 5, that's the SOQL limit)export beta
andimport beta
handle objects that refer to objects of the same type (ex: Account with ParentId, User with Manager)import beta
using--plan
handles more than 200 records. It will batch them into groups of 200 per object. The new record limit is not documented--it most likely comes from your OS call stack depth or other org limits (data storage, api call limits)import
supported plan files where thefiles
property could contain objects. I'm really not sure how those files were generated, but I don't think the export command made them. Forimport beta
only work with strings and will throw an error otherwise.import beta
in--files
mode (not--plan
) will import the files in parallel (files can't reference each other without--plan
)import
provides deprecation warnings for bothcontent-type
andconfig-help
flagsExport files created by
export beta
are compatible withimport
andimport beta
Phase 2: GA the new commands, put the old under
legacy
. [July 10 2024]legacy
and mark themhidden
anddeprecated
with the Phase 3 dateforce:
aliases to the new commandsbeta
but have thebeta
alias. adddeprecateAliases
so people stop using thebeta
thing.export
with--json
to warn that it will change json output (stop returning the saveRefs/resolveRefs) after Phase 3 datePhase 3: retire the legacy commands and all their dependent code [Nov 10 2024]
export
stop writing the unusedsaveRefs
andresolveRefs
properties on plan files, and stop returning them in jsonobject
part offiles
, and removesaveRefs
andresolveRefs
beta
alias fromimport|export
changes
What issues does this PR fix or reference?
forcedotcom/cli#2663
@W-14876905@
@W-14980455@
forcedotcom/cli#248
QA notes
the query provided in the repro will get data and create files, but they aren't
import
able because of required fields on Events. This query will let you round trip it