Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

Query Parser Rewrite #51

Merged

Conversation

StevenMMortimer
Copy link
Contributor

@StevenMMortimer StevenMMortimer commented Dec 1, 2016

Rewrite the SOQL XML parsing function to simplify and close known issues. Below is a list of these issues and examples of these issues that now execute properly with the new parser.

For individuals who want to test this fix please re-install RForcecom using the following command:

devtools::install_github('ReportMort/RForcecom', ref='bugfix/query-parser-rewrite')

I would appreciate any help from others in verifying that this works for as many query types as possible.


Tested Examples based on Outstanding Issues:
#37, #48

#works with parent-child query that requests fields from each object
query <- "SELECT 
              Id
            , StageName
            , Account.Name 
          FROM Opportunity
          LIMIT 5"
rforcecom.query(session, query)

#works with parent-child query that only requests fields from the parent only
query <- "SELECT 
              Account.Id
            , Account.Name 
          FROM Opportunity
          LIMIT 5"
rforcecom.query(session, query)

#works with grandparent-parent-child query that requests fields from each object
query <- "SELECT 
              Id
            , Name
            , Parent.Id
            , Parent.Name
            , Parent.RecordType.Name
            , Parent.Parent.Id
            , Parent.Parent.Name
            FROM Account 
            WHERE Parent.RecordType.Name in ('Tier1')"
rforcecom.query(session, query)

#41
note that SELECT COUNT() still returns null, but the preferred method would be to supply a field to count and then it will return as expected

# simple count works
query <- "SELECT 
              COUNT(Id) cnt
          FROM Opportunity"
rforcecom.query(session, query)

# count works with multiple fields and aliases for each
query <- "SELECT 
              COUNT(Id) oppy_cnt
            , COUNT(CampaignId) campaign_cnt
          FROM Opportunity"
rforcecom.query(session, query)

# count works with a GROUP BY statement
query <-"SELECT 
              LeadSource
            , COUNT(Name) lead_cnt
         FROM Lead
         GROUP BY LeadSource"
rforcecom.query(session, query)

#45

# works with queries pulling field history information 
query <- "SELECT 
            Id
          , IsDeleted
          , OpportunityId
          , CreatedDate
          , Field
          , OldValue
          , NewValue
          FROM OpportunityFieldHistory 
          WHERE 
                CreatedDate >= 2016-11-01T00:00:00Z 
            AND (Field='StageName' OR Field='Amount')"
rforcecom.query(session, query)

Change how the query parser function works so that is easier to understand, more flexible, and fixes hiratake55#37, fixes hiratake55#41, and fixes hiratake55#45
@hiratake55
Copy link
Owner

Thanks, Merged.

@hiratake55 hiratake55 merged commit 2c1bd45 into hiratake55:master Dec 11, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants