Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove quotes from sample code in apex docs #503

Merged
merged 1 commit into from
Jan 19, 2024
Merged

Conversation

pchittum
Copy link
Contributor

What does this PR do?

In the apex docs for the SOQLRecipes.cls, the code example is shown as follows:

System.debug('SOQLRecipes.getSecond10AccountRecords()');

The trouble is, the code snippet SOQLRecipes.getSecond10AccountRecords() needs to be executed, not passed as a string literal.

When run as currently committed, here's the output from exec anonymous:

> sf apex run       
Start typing Apex code. Press the Enter key after each line, then press CTRL+D when finished.
System.debug('SOQLRecipes.getSecond10AccountRecords()');
Compiled successfully.
Executed successfully.

59.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO
Execute Anonymous: System.debug('SOQLRecipes.getSecond10AccountRecords()');
15:29:36.47 (47706067)|USER_INFO|[EXTERNAL]|0058e000000ocr8|[email protected]|(GMT+00:00) Greenwich Mean Time (Europe/London)|GMTZ
15:29:36.47 (47743017)|EXECUTION_STARTED
15:29:36.47 (47761454)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
15:29:36.47 (48548353)|USER_DEBUG|[1]|DEBUG|SOQLRecipes.getSecond10AccountRecords()
15:29:36.48 (48692284)|CUMULATIVE_LIMIT_USAGE
15:29:36.48 (48692284)|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 0 out of 100
  Number of query rows: 0 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of Publish Immediate DML: 0 out of 150
  Number of DML rows: 0 out of 10000
  Maximum CPU time: 0 out of 10000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 100
  Number of Email Invocations: 0 out of 10
  Number of future calls: 0 out of 50
  Number of queueable jobs added to the queue: 0 out of 50
  Number of Mobile Apex push calls: 0 out of 10

15:29:36.48 (48692284)|CUMULATIVE_LIMIT_USAGE_END

15:29:36.47 (48768612)|CODE_UNIT_FINISHED|execute_anonymous_apex
15:29:36.47 (48784518)|EXECUTION_FINISHED

Obviously, no soql was actually executed in this transaction. Meaning the code doesn't do what it's supposed to do: demonstrate execution of the code.

When removing the single quotes, the transaction reports back as follows:

> sf apex run 
Start typing Apex code. Press the Enter key after each line, then press CTRL+D when finished.
> System.debug(SOQLRecipes.getSecond10AccountRecords());
Compiled successfully.
Executed successfully.

59.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO
Execute Anonymous: System.debug(SOQLRecipes.getSecond10AccountRecords());
15:31:07.123 (123137120)|USER_INFO|[EXTERNAL]|0058e000000ocr8|[email protected]|(GMT+00:00) Greenwich Mean Time (Europe/London)|GMTZ
15:31:07.123 (123174396)|EXECUTION_STARTED
15:31:07.123 (123191352)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
15:31:07.123 (179195355)|USER_DEBUG|[1]|DEBUG|(Account:{Id=0018e00000FSdefAAD}, Account:{Id=0018e00000FSdepAAD}, Account:{Id=0018e00000FGRKMAA5})
15:31:07.179 (179325681)|CUMULATIVE_LIMIT_USAGE
15:31:07.179 (179325681)|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 1 out of 100
  Number of query rows: 3 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of Publish Immediate DML: 0 out of 150
  Number of DML rows: 0 out of 10000
  Maximum CPU time: 0 out of 10000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 100
  Number of Email Invocations: 0 out of 10
  Number of future calls: 0 out of 50
  Number of queueable jobs added to the queue: 0 out of 50
  Number of Mobile Apex push calls: 0 out of 10

15:31:07.179 (179325681)|CUMULATIVE_LIMIT_USAGE_END

15:31:07.123 (179445851)|CODE_UNIT_FINISHED|execute_anonymous_apex
15:31:07.123 (179457690)|EXECUTION_FINISHED

Here we actually get a soql query and some soql rows reported back. This is the correct invocation of the code that demonstrates the use of this method.

What issues does this PR fix or reference?

#

The PR fulfills these requirements:

[X] Tests for the proposed changes have been added/updated.
[X] Code linting and formatting was performed.

[no actual changes to code were made, only to comments and to documentation.]

Functionality Before

Execution of the code did not occur

Functionality After

The code executes as expected.

@pchittum pchittum requested a review from a team as a code owner January 18, 2024 15:57
@msrivastav13
Copy link
Contributor

Thank you @pchittum for spotting the issue and fixing!!

@msrivastav13 msrivastav13 enabled auto-merge (squash) January 19, 2024 12:21
@pozil pozil disabled auto-merge January 19, 2024 16:39
@pozil pozil merged commit 2132f1e into trailheadapps:main Jan 19, 2024
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants