PropicSignifi / Query.apex

A dynamic SOQL and SOSL query builder on Salesforce.com platform
https://propicsignifi.github.io/query-apex/
MIT License
153 stars 68 forks source link

Support FORMAT() for Currency fields #74

Open aranwe opened 3 years ago

aranwe commented 3 years ago

Currently if you try to add Query.selectField('FORMAT(Amount) Amount') the Query formating fails on: checkFieldLevelSecurity(Schema.SObjectType objType, String fieldPath) because it tries to get the whole String from fieldMap.

FunctionFieldTuples are supported only in aggregate queries.

Either there should be regexp that would support FORMAT() in checkFieldLevelSecurity or there should be some more advanced mechanism to allow FunctionFieldTuples in non-aggregation queries ... though SOQL supports only FORMAT() as function call in non-aggregation queries?

What do you think?

Cheers, O.

HenryRLee commented 3 years ago

Hi @aranwe, I think we should allow FunctionFieldTuple in non-aggregation queries. Actually, I believe if we add a function that does functionFieldList.add(new FunctionFieldTuple('FORMAT', field, alias)), it will work. It's just the method name formAggregateString creates confusion and makes people think FunctionFieldTuple are only used in aggregation queries. So it'd be better if we rename the method name also.

Do you want to work on a PR for this?

aranwe commented 3 years ago

Oh, you're right, I haven't noticed that the formAggregateString is called in all Query Strings (as long as there are functionFields). Thought there was separate method for aggregation queries and normal for some reason. :) Then yeah, it makes sense.

I can create PR but in ~a month, I'll be OOO, if anyone feels like playing with it - go ahead :)