forcedotcom / forcedotcom/go-soql
Add support min/max functions
- Dominant language
- Go
- Stars
- 53
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
As part of supporting aggregate functions add support for following functions:
```
MIN()
MAX()
```
Add `min` and `max` tag that can be used in `selectClause` structs as follows:
```
type TestSoqlStruct struct {
SelectClause NestedStruct `soql:"selectClause,tableName= Contact"`
GroupBy []string `soql:"groupByClause"`
}
type NestedStruct struct {
FirstName string `soql:"selectColumn,fieldName=FirstName"`
LastName string `soql:"selectColumn,fieldName=LastName"`
Count int `soql:"min,fieldName= CreatedDate"`
}
soqlStruct := TestSoqlStruct{
GroupBy: []string{"FirstName", "LastName"},
}
soqlQuery, err := Marshal(soqlStruct)
if err != nil {
fmt.Printf("Error in marshaling: %s\n", err.Error())
}
fmt.Println(soqlQuery)
```
This should result in SOQL as follows
```
SELECT FirstName, LastName, MIN(CreatedDate) FROM Contact GROUP BY FirstName, LastName'
```
Note that if `fieldName` is not specified then return `ErrInvalidTag`.
Same should apply for `max` tag as well.
Allow `min` and `max` to be used only for supported primitive [data types](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_agg_functions_field_types.htm)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.