Open atulkc opened 4 years ago
As part of supporting aggregate functions add support for following functions:
AVG() SUM()
Add avg and sum tag that can be used in selectClause structs as follows:
avg
sum
selectClause
type TestSoqlStruct struct { SelectClause NestedStruct `soql:"selectClause,tableName= Opportunity"` GroupBy []string `soql:"groupByClause"` } type NestedStruct struct { CampaignId string `soql:"selectColumn,fieldName= CampaignId"` Average int `soql:"avg,fieldName= Amount"` } soqlStruct := TestSoqlStruct{ GroupBy: []string{"CampaignId"}, } 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 CampaignId, AVG(Amount) FROM Opportunity GROUP BY CampaignId
Note that if fieldName is not specified then return ErrInvalidTag.
fieldName
ErrInvalidTag
Same should apply for sum tag as well.
Allow avg and sum to be used only for supported primitive data types
As part of supporting aggregate functions add support for following functions:
Add
avg
andsum
tag that can be used inselectClause
structs as follows:This should result in SOQL as follows
Note that if
fieldName
is not specified then returnErrInvalidTag
.Same should apply for
sum
tag as well.Allow
avg
andsum
to be used only for supported primitive data types