GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [apex] Provide access to underlying query of SoqlExpression · Issue #2136 · pmd/pmd

[apex] Provide access to underlying query of SoqlExpression #2136

New issue
Copy link
New issue
Copy link
Closed
#2137
Closed
[apex] Provide access to underlying query of SoqlExpression#2136
#2137
Copy link
Labels
an:enhancementAn improvement on existing features / rules
Milestone
6.20.0

Description

@r-r-a-j
r-r-a-j
opened on Nov 28, 2019
Issue body actions

image

PMD Version:
6.19

Description:
(New to PMD & Xpath so please forgive a newbie question!)

I can see the SoqlExpression in the AST but I need to parse the SOQL itself, however there is no Image attribute (is this the correct attribute I should be looking for??), nor is there any other further break down element that I can interrogate. I wish to avoid writing a Java class if at all possible and simply use Xpath.

Code Sample demonstrating the issue:

public class Foo 
{
	public void test1() 
	{
	    Account acc = [Select 1 FROM Account ];
	    Account acc = [Select 2 FROM Account where x = x];
	    Account acc = [Select 2 FROM Account where x = x WITH SECURITY_ENFORCED];
	}
}

XPath-Expression: //SoqlExpression

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
Designer from CLI

Activity

  1. adangel
    changed the title [-][Apex] Parsing SoqlExpression[/-] [+][apex] Parsing SoqlExpression[/+] on Nov 28, 2019
  2. adangel
    added
    an:enhancementAn improvement on existing features / rules
    on Nov 28, 2019
  3. adangel
    changed the title [-][apex] Parsing SoqlExpression[/-] [+][apex] Provide access to underlaying query of SoqlExpression[/+] on Nov 28, 2019
  4. adangel
    added a commit that references this issue on Nov 28, 2019

    [apex] Provide access to underlying query of SoqlExpression

    This issue will close once commit cdf11ed is merged into the 'main' branch.
    cdf11ed
  5. adangel commented on Nov 28, 2019

    @adangel
    adangel
    on Nov 28, 2019
    Member
    More actions

    Hi @r-r-a-j ,
    that's not possible at the moment - but it's easy to add. The SoqlExpression node has access to the underlying query, but that is just not exposed as an xpath attribute.

    Note, that the query is a simple string - there is no further structure. But you could then write a rule e.g. that finds all queries with this "security enforced" flag:

    //SoqlExpression[contains(@Query, 'WITH SECURITY_ENFORCED')]

    I've created a PR for that: #2137

  6. adangel
    changed the title [-][apex] Provide access to underlaying query of SoqlExpression[/-] [+][apex] Provide access to underlying query of SoqlExpression[/+] on Nov 28, 2019
  7. adangel
    added this to the 6.20.0 milestone on Nov 28, 2019
  8. adangel
    closed this as completedin cdf11edon Nov 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    an:enhancementAn improvement on existing features / rules

    Type

    No type

    Projects

    No projects

      Milestone

      • 6.20.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.