Marshal SOQL queries with OR operators between different columns. For example, I don't believe this query is currently marshal-able:
SELECT Name,Email,Phone
FROM Contact
WHERE Title = 'Purchasing Manager' OR Department = 'Accounting'
I've been playing with an implementation that I think might work and is in keeping with the current patterns: adding an optional clause tag called joiner for whereClause. If not set, the marshal function uses AND to join (to maintain current functionality). If it's set to OR (case insensitive), then it will separate the clauses with OR.
type contact struct {
Name string `soql:"selectColumn,fieldName=Name" json:"Name"`
Email string `soql:"selectColumn,fieldName=Email" json:"Email"`
Phone string `soql:"selectColumn,fieldName=Phone" json:"Phone"`
}
type orSOQLQuery struct {
SelectClause contact `soql:"selectClause,tableName=Contact"`
WhereClause positionOrDeptCriteria `soql:"whereClause,joiner=OR"`
}
type positionOrDeptCriteria struct {
Title string `soql:"equalsOperator,fieldName=Title"`
Department string `soql:"equalsOperator,fieldName=Department"`
}
// this would generate the soql query
soql.Marshal(orSOQLQuery{
WhereClause: positionOrDeptCriteria{
Title: "Purchasing Manager",
Department: "Accounting",
},
})
Marshal SOQL queries with
OR
operators between different columns. For example, I don't believe this query is currently marshal-able:I've been playing with an implementation that I think might work and is in keeping with the current patterns: adding an optional clause tag called
joiner
forwhereClause
. If not set, the marshal function usesAND
to join (to maintain current functionality). If it's set toOR
(case insensitive), then it will separate the clauses withOR
.