turbot / steampipe-plugin-salesforce

Use SQL to instantly query Salesforce resources. Open source CLI. No DB required.
https://hub.steampipe.io/plugins/turbot/salesforce
Apache License 2.0
9 stars 6 forks source link

Remove/Disable Snake Casing for Field Names and Object Names #13

Closed d416 closed 1 year ago

d416 commented 1 year ago

Is your feature request related to a problem? Please describe. As a Salesforce developer, I find it confusing to have all the API names of Fields and Objects changed to snake case. Can this behaviour be removed from the plugin or optionally disabled? For Salesforce devs, the plugin isn't very useful with these name transformations. (see alternatives and additional context below)

Describe the solution you'd like API names of fields and objects in Salesforce should be queryable as-is without snake casing, so dual-word field names like 'CreatedDate' should not be changed to 'created_date', and for objects, names like PermissionSet are now 'permission_set'. It would also be useful to keep the full proper case (capitalization as defined) on a field and object instead of lowercasing the name, but if this is an issue with case sensitivity in golang then all lowercase would be the best option here.

Describe alternatives you've considered The alternative is for Salesforce devs to learn what the new transformed names of fields and objects when querying. Many of us (SF developers) are already familiar with our schema, so we'd need to un-learn this.

Additional context Many SF devs use SOQL which is similar to SQL and so are quite familiar with all the field names in an object as they need to be recalled from memory when building a query.

cbruno10 commented 1 year ago

Hey @d416 , thanks for opening this issue, along with others, and putting a lot of detail into them!

Our original design behind snake casing everything was to make queries a bit easier, e.g., select created_date from permission_set instead of select "CreatedDate" from "PermissionSet". But, I can see where this creates confusion, especially if SF users are not used to this scheme.

If we were to offer some config arg that let you toggle column/table name casing, so you could leave every name in its native format, would that help make querying easier?

d416 commented 1 year ago

If we were to offer some config arg that let you toggle column/table name casing, so you could leave every name in its native format, would that help make querying easier?

Sure, as long as we aren't adding any underscores in between compound words, so that the field API name in Salesforce matches what is queryable in the plugin. Examples:

Field API name in Salesforce: CreatedDate

Queryable names in Steampipe Salesforce plugin:

createddate - if only this is allowed that's ok CreatedDate - ideally both the matching case of the API name and the lower-case as per above CrEaTeDdAtE - super ideally any case! maybe not practical for performance reasons

It's up to you whether to allow created_date, but any Salesforce admin/user who would use this naming convention in a query would be a complete masochist : )

Thanks for getting back

cbruno10 commented 1 year ago

For this feature request and https://github.com/turbot/steampipe-plugin-salesforce/issues/16, here's a proposal:

Other plugins with dynamic tables like CSV and Google Sheets don't change table or column names, so the Salesforce plugin arguably shouldn't either.

We could set the default values for both args above to be true, but eventually change their default values to false in a future breaking change to keep the Salesforce plugin consistent with other dynamic plugins.

johnsmyth commented 1 year ago

@cbruno10 I am not familiar enough with salesforce to have a strong opinion on what the default should be but:

cbruno10 commented 1 year ago

@johnsmyth The plugin has been out for a while, but I'm not sure of overall usage among users. Instead of offering a path with deprecation and gradual change through config args, we could make the Salesforce plugin consistent with the other dynamic plugins we have and remove the prefix/snake casing all together now.

If we were to offer toggles around snake casing, adding a prefix, etc., I think we'd probably do so across all dynamic plugins and probably based on user requests (which we haven't seen in other dynamic plugins so far).

cbruno10 commented 1 year ago

Based on discussions above, we could add a single config arg that would control the salesforce_ prefix and snake casing of table and column names. By default, it should be set so the current behaviour is preserved, but can be adjusted so users can have the Salesforce plugin behave like most other dynamic plugins, i.e., no changing of table and column names from native format, no added prefix.

This config arg should also be an enum, e.g., name_scheme = PostgreSQL/SOQL, instead of a boolean, to allow for more flexibility.

d416 commented 1 year ago

Based on the comments above, the only reason to add a configurable option to disable camel case is to not disrupt the people who are using this plugin, however based on all the issues logged on this repo (and lack of telemetry to prove otherwise), I am the only one. Therefore, please avoid the bloat and claw back this ‘feature’ to transform properly-governed REST api names into camel case which appears to have not been granted any value from anyone.

johnsmyth commented 1 year ago

@d416 You can argue that the default should be original case, but I do believe there is still a place for the snake cased names - you don't have to quote all the table and column names.

cbruno10 commented 1 year ago

@d416 I agree that you're the only one who's raised an issue or participated in these discussions, but we do know that other users are engaging with the Salesforce plugin today (based on messages in our Slack or other communication channels). So ideally we don't want to break their plugin use today, especially if they don't know it's coming since they don't check GitHub issues. So we will still most likely proceed with adding a config arg as mentioned above.

bigdatasourav commented 1 year ago

@d416, we have introduced a config parameter name naming_convention to support the control for the salesforce_ prefix and snake casing of table and column names. The parameter is an enum type with supported values api_native/snake_case. If a user sets the parameter with the value api_native, there will be no prefix for the table name and object, and column names will not be in the snake case.

Sample output -

image (8)

image (7)

I have raised a PR with the above changes. Could you please try it out and let us know your feedback?

Steps to follow -