Comments¶
Comments are used to add explanatory notes or remarks to statements within a GQL query. They are ignored by the interpreter and do not affect query execution.
GQL supports two types of comments:
- Simple comments (single-line comments)
- Bracketed comments (multi-line comments)
Use either comment form to annotate a query.
Simple comments¶
Simple comments are used to add explanatory text or remarks on a single line. They start with // or -- and extend to the end of the line.
Syntax rules¶
- Symbols:
//or-- - Scope: From the symbol to the end of the line. Simple comments are only used on single lines. To add comments on multiple lines, use symbols
//or--at the beginning of each line or use bracketed comments. - Placement: Can be standalone or appended after a statement.
Examples¶
The following examples are only used to demonstrate comment placement and syntax. They are not tied to a specific product entry point.
'''
// Example: A standalone simple comment
-- Explain the purpose of the next statement
statement_1
statement_2 -- Explain what this statement does.
'''
Bracketed comments¶
Bracketed comments are used to add explanatory text or remarks on one or more lines. They start with /* and end with */, and they can span multiple lines.
Syntax rules¶
- Symbols:
/*and*/ - Scope: From the opening symbol to the closing symbol.
- Constraint: The closing symbol
*/cannot appear within a bracketed comment; otherwise, it leads to a premature end of the comment. - Placement: Can be standalone or appended after a statement.
Examples¶
The following examples are only used to demonstrate comment placement and syntax. They are not tied to a specific product entry point.
'''
/* Example: A multi-line bracketed comment
Describe complex query logic here */
statement_1
statement_2
/* Single-line bracketed comment example */
statement_3 /* This comment explains what this statement does */
'''
The following is an error example of a bracketed comment that contains */:
'''
/* Error example: comment contains the closing symbol */ */
statement_1
statement_2
'''
Note
The second */ in the comment is treated as the closing symbol, which leads to a premature end of the comment.