forcedotcom / SFDX-Data-Move-Utility

SFDMU is a cutting-edge Salesforce data migration tool for seamless org population from other orgs or CSV files. It handles all CRUD operations on multiple related objects in one go.
BSD 3-Clause "New" or "Revised" License
456 stars 75 forks source link

[FEATURE REQUEST] Being able to put the query in a separate .soql file #900

Closed thvd closed 1 month ago

thvd commented 1 month ago

I am frustrated to put the query (with many fields) in the export.json file on one line.

Describe the solution you'd like

So just like sf data export tree i would like to use the query in a formatted way in a myQuery.soql file.

Like this:

export.json:

{
  "objects": [
    {
      "query": "config/data/testdata.soql",
      "operation": "Upsert"
    }
  ]
}

config/data/testdata.soql:

SELECT Id, 
   Name
FROM Account
LIMIT 10

How to implement this

I have been looking at the code, i think if we put this code:

    if (query.endsWith('.soql') && fs.existsSync(query)) {
      query = fs.readFileSync(query, 'utf8');
    }

in the _parseQuery method of src/modules/models/script_models/scriptObject.ts will that implement this?

hknokh commented 1 month ago

Hello, @thvd

Thank you for your feature request. I will review it as soon as possible and provide updates as they become available.

Cheers

hknokh2 commented 1 month ago

Hey,
The setup() method, which includes the _parseQuery() method, is being called multiple times on modified and internally created object configurations, not just on the one defined in export.json. This makes the implementation more complex than simply reading from the disk.
Could you explain the use case ?

github-actions[bot] commented 1 month ago

This case has been marked as 'to-be-closed', since it has no activity for the 3 days.
It will be automatically closed in another 3 days of inactivity.

hknokh commented 1 month ago

This case is postponed for the future review and closed for the current moment.

thvd commented 1 month ago

Hey, The setup() method, which includes the _parseQuery() method, is being called multiple times on modified and internally created object configurations, not just on the one defined in export.json. This makes the implementation more complex than simply reading from the disk. Could you explain the use case ?

@hknokh Hey, of course i will explain the use case.

So the challenge I experience is that the query JSON node becomes hard to maintain with a large query. Let's say you will fetch 20 (or more) fields and you add a large WHERE clause, then I fear I need to put the whole query on one line in the JSON. This makes it hard to read and maintain.