Skip to content

Commit c64e8b1

Browse files
committed
Change behavior to default inclusion
1 parent 7dcb7f0 commit c64e8b1

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

utils/pg-sql2/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const isDev =
3333
(process.env.GRAPHILE_ENV === "development" ||
3434
process.env.GRAPHILE_ENV === "test");
3535

36-
const alwaysIncludeComments =
36+
const defaultIncludeComments =
3737
isDev || (typeof process !== "undefined" && process.env.PGSQL2_DEBUG === "1");
3838

3939
const nodeInspect: CustomInspectFunction = function (
@@ -1101,9 +1101,9 @@ export function placeholder(symbol: symbol, fallback?: SQL): SQL {
11011101

11021102
export function comment(
11031103
text: string,
1104-
always = false,
1104+
include = defaultIncludeComments,
11051105
): SQLCommentNode | SQLRawNode {
1106-
if (always || alwaysIncludeComments) {
1106+
if (include) {
11071107
return makeCommentNode(text);
11081108
} else {
11091109
return sql.blank;

utils/website/pg-sql2/api/sql-comment.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ sidebar_position: 10
33
title: "sql.comment()"
44
---
55

6-
# `sql.comment(text, always)`
6+
# `sql.comment(text, include)`
77

88
Creates an SQL comment fragment that can be embedded in queries. Comments are
99
useful for documenting query logic, adding debugging information, or providing
1010
context for complex operations.
1111

1212
Comments are ignored during SQL execution by default but
13-
can be valuable for debugging and maintenance; comments only appear when
14-
[`GRAPHILE_ENV=development`](../development-mode.md) is set or if `always` is `true`.
13+
can be valuable for debugging and maintenance. By default, comments only appear when
14+
[`GRAPHILE_ENV=development`](../development-mode.md) is set, but you can force
15+
them to appear by setting `include` to `true` (or force them to be hidden via
16+
`include` set to `false`).
1517

1618
:::warning[Do not include user-generated content!]
1719

@@ -24,12 +26,13 @@ vulnerable SQL.
2426
## Syntax
2527

2628
```typescript
27-
sql.comment(text: string, always: true): SQL
29+
sql.comment(text: string, include?: boolean): SQL
2830
```
2931

3032
## Parameters
3133

3234
- `text` - The comment text to include
35+
- `include` - Optional boolean to force inclusion (`true`) or exclusion (`false`) of the comment regardless of environment. Defaults to `undefined`, which means comments are included only in development mode.
3336

3437
## Return value
3538

0 commit comments

Comments
 (0)