Skip to content

Commit 7b6aa09

Browse files
authored
Update introduction-to-ql.rst
1 parent b89dd3d commit 7b6aa09

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

docs/codeql/writing-codeql-queries/introduction-to-ql.rst

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,19 @@ QL also supports recursion and aggregates. This allows you to write complex recu
1717
Running a query
1818
---------------
1919

20-
You can try out the following examples and exercises using :ref:`CodeQL for VS Code <codeql-for-visual-studio-code>`, or you can run them in GitHub Codespaces using the `CodeQL template <https://github.com/codespaces/new?template_repository=github/codeql-codespaces-template>`__. To access the template, click on the link then click **Use this template**. This will open a GitHub Codespaces environment that is preconfigured to run CodeQL queries.
20+
You can try out the following examples and exercises using :ref:`CodeQL for VS Code <codeql-for-visual-studio-code>`, or you can run them in GitHub Codespaces using the `CodeQL template <https://github.com/codespaces/new?template_repository=github/codeql-codespaces-template>`__. This will open a GitHub Codespaces environment preconfigured to run CodeQL queries.
2121

22-
Once you open the GitHub Codespaces template, follow the instructions in the ReadMe to take a code tour and learn how to run queries in the workspace.
22+
Once you open the GitHub Codespaces template, follow the instructions in the README to take a code tour and learn how to run queries in the workspace.
2323

24-
The first query in the `tutorial.ql` file is populated with the query:
24+
Here is an example of a basic query:
2525

2626
.. code-block:: ql
2727
2828
import tutorial
2929
30-
from Person p
31-
select p
30+
select "hello world"
3231
33-
This query returns a list of people in the tutorial's database.
32+
This query returns the string `"hello world"`.
3433

3534
More complicated queries typically look like this:
3635

@@ -60,7 +59,7 @@ Exercise 1
6059

6160
Write a query which returns the length of the string ``"lgtm"``. (Hint: `here <https://codeql.github.com/docs/ql-language-reference/ql-language-specification/#built-ins-for-string>`__ is the list of the functions that can be applied to strings.)
6261

63-
➤ `Check your answer <#exercise-1>`__
62+
➤ `Check your answer <#answer:-exercise-1>`__
6463

6564
There is often more than one way to define a query. For example, we can also write the above query in the shorter form:
6665

@@ -73,21 +72,21 @@ Exercise 2
7372

7473
Write a query which returns the sine of the minimum of ``3^5`` (``3`` raised to the power ``5``) and ``245.6``.
7574

76-
➤ `Check your answer <#exercise-2>`__
75+
➤ `Check your answer <#answer:-exercise-2>`__
7776

7877
Exercise 3
7978
~~~~~~~~~~
8079

8180
Write a query which returns the opposite of the boolean ``false``.
8281

83-
➤ `Check your answer <#exercise-3>`__
82+
➤ `Check your answer <#answer:-exercise-3>`__
8483

8584
Exercise 4
8685
~~~~~~~~~~
8786

8887
Write a query which computes the number of days between June 10 and September 28, 2017.
8988

90-
➤ `Check your answer <#exercise-4>`__
89+
➤ `Check your answer <#answer:-exercise-4>`__
9190

9291
Example query with multiple results
9392
-----------------------------------
@@ -175,9 +174,7 @@ Further reading
175174
Answers
176175
-------
177176

178-
In these answers, we use ``/*`` and ``*/`` to label the different parts of the query. Any text surrounded by ``/*`` and ``*/`` is not evaluated as part of the QL code, but is treated as a *comment*.
179-
180-
Exercise 1
177+
Answer: Exercise 1
181178
~~~~~~~~~~
182179

183180
.. code-block:: ql
@@ -186,7 +183,7 @@ Exercise 1
186183
where s = "lgtm"
187184
select s.length()
188185
189-
Exercise 2
186+
Answer: Exercise 2
190187
~~~~~~~~~~
191188

192189
.. code-block:: ql
@@ -195,7 +192,7 @@ Exercise 2
195192
where x = 3.pow(5) and y = 245.6
196193
select x.minimum(y).sin()
197194
198-
Exercise 3
195+
Answer: Exercise 3
199196
~~~~~~~~~~
200197

201198
.. code-block:: ql
@@ -204,7 +201,7 @@ Exercise 3
204201
where b = false
205202
select b.booleanNot()
206203
207-
Exercise 4
204+
Answer: Exercise 4
208205
~~~~~~~~~~
209206

210207
.. code-block:: ql

0 commit comments

Comments
 (0)