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

Make describe easier to call #31

Closed
rferg opened this issue Apr 12, 2023 · 0 comments · Fixed by #36
Closed

Make describe easier to call #31

rferg opened this issue Apr 12, 2023 · 0 comments · Fixed by #36
Assignees
Labels
enhancement New feature or request

Comments

@rferg
Copy link
Contributor

rferg commented Apr 12, 2023

This is sometimes useful to call from the Rails console during development time to get the metadata for an sObject (e.g., required fields, relationship names, etc.). However, you have to call it by getting a reference to the sfdc_client, something like this:

model = Af::Campaign
ActiveForce.sfdc_client.describe(model.table_name)

Seems like it would be really easy to add as a class method on SObject, since sfdc_client and table_name are already available on that class. So it would instead look like this:

Af::Campaign.describe

Then we could add some convenience methods for filtering through that response for common cases, like checking if a field is nillable or getting a relationship name, etc.

Long-term, this might be useful to have for building more optimized queries that deal with relationships (e.g., "joins"). If we could cache this response on the class and then re-use that to build queries. Although I haven't really thought this through very much.

@rferg rferg added the enhancement New feature or request label Apr 12, 2023
@rferg rferg linked a pull request Apr 17, 2023 that will close this issue
@rferg rferg self-assigned this Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant