Skip to content

Commit 0e8bfa9

Browse files
committed
sqlite: rename verbose to trace
1 parent 51a3ee4 commit 0e8bfa9

File tree

5 files changed

+26
-28
lines changed

5 files changed

+26
-28
lines changed

doc/api/sqlite.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ added: v22.5.0
109109
changes:
110110
- version: REPLACEME
111111
pr-url: https://github.com/nodejs/node/pull/62241
112-
description: Add `verbose` option.
112+
description: Add `trace` option.
113113
- version:
114114
- v25.5.0
115115
- v24.14.0
@@ -183,7 +183,7 @@ changes:
183183
* `likePatternLength` {number} Maximum length of a LIKE pattern.
184184
* `variableNumber` {number} Maximum number of SQL variables.
185185
* `triggerDepth` {number} Maximum trigger recursion depth.
186-
* `verbose` {Function} An optional callback function that is invoked for
186+
* `trace` {Function} An optional callback function that is invoked for
187187
every SQL statement executed against the database. The callback receives
188188
the expanded SQL string (with bound parameter values substituted) as its
189189
only argument. If expansion fails, the source SQL (with unsubstituted
@@ -1576,8 +1576,8 @@ callback function to indicate what type of operation is being authorized.
15761576
[`sqlite3_load_extension()`]: https://www.sqlite.org/c3ref/load_extension.html
15771577
[`sqlite3_prepare_v2()`]: https://www.sqlite.org/c3ref/prepare.html
15781578
[`sqlite3_set_authorizer()`]: https://sqlite.org/c3ref/set_authorizer.html
1579-
[`sqlite3_trace_v2()`]: https://www.sqlite.org/c3ref/trace_v2.html
15801579
[`sqlite3_sql()`]: https://www.sqlite.org/c3ref/expanded_sql.html
1580+
[`sqlite3_trace_v2()`]: https://www.sqlite.org/c3ref/trace_v2.html
15811581
[`sqlite3changeset_apply()`]: https://www.sqlite.org/session/sqlite3changeset_apply.html
15821582
[`sqlite3session_attach()`]: https://www.sqlite.org/session/sqlite3session_attach.html
15831583
[`sqlite3session_changeset()`]: https://www.sqlite.org/session/sqlite3session_changeset.html

src/env_properties.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@
370370
V(url_string, "url") \
371371
V(username_string, "username") \
372372
V(value_string, "value") \
373-
V(verbose_string, "verbose") \
373+
V(trace_string, "trace") \
374374
V(verify_error_string, "verifyError") \
375375
V(version_string, "version") \
376376
V(windows_hide_string, "windowsHide") \

src/node_sqlite.cc

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ bool DatabaseSync::Open() {
976976

977977
{
978978
Local<Value> cb =
979-
object()->GetInternalField(kVerboseCallback).template As<Value>();
979+
object()->GetInternalField(kTraceCallback).template As<Value>();
980980
if (cb->IsFunction()) {
981981
sqlite3_trace_v2(
982982
connection_, SQLITE_TRACE_STMT, DatabaseSync::TraceCallback, this);
@@ -1349,21 +1349,19 @@ void DatabaseSync::New(const FunctionCallbackInfo<Value>& args) {
13491349
}
13501350
}
13511351

1352-
// Parse verbose option
1353-
Local<Value> verbose_v;
1354-
if (!options->Get(env->context(), env->verbose_string())
1355-
.ToLocal(&verbose_v)) {
1352+
// Parse trace option
1353+
Local<Value> trace_v;
1354+
if (!options->Get(env->context(), env->trace_string()).ToLocal(&trace_v)) {
13561355
return;
13571356
}
1358-
if (!verbose_v->IsUndefined() && !verbose_v->IsNull()) {
1359-
if (!verbose_v->IsFunction()) {
1357+
if (!trace_v->IsUndefined() && !trace_v->IsNull()) {
1358+
if (!trace_v->IsFunction()) {
13601359
THROW_ERR_INVALID_ARG_TYPE(
13611360
env->isolate(),
1362-
"The \"options.verbose\" argument must be a function.");
1361+
"The \"options.trace\" argument must be a function.");
13631362
return;
13641363
}
1365-
args.This()->SetInternalField(kVerboseCallback,
1366-
verbose_v.As<Function>());
1364+
args.This()->SetInternalField(kTraceCallback, trace_v.As<Function>());
13671365
}
13681366
}
13691367

@@ -2431,7 +2429,7 @@ int DatabaseSync::TraceCallback(unsigned int type,
24312429
Local<Context> context = env->context();
24322430

24332431
Local<Value> cb =
2434-
db->object()->GetInternalField(kVerboseCallback).template As<Value>();
2432+
db->object()->GetInternalField(kTraceCallback).template As<Value>();
24352433

24362434
if (!cb->IsFunction()) {
24372435
return 0;

src/node_sqlite.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class DatabaseSync : public BaseObject {
165165
enum InternalFields {
166166
kAuthorizerCallback = BaseObject::kInternalFieldCount,
167167
kLimitsObject,
168-
kVerboseCallback,
168+
kTraceCallback,
169169
kInternalFieldCount
170170
};
171171

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ const assert = require('node:assert');
77
const { DatabaseSync } = require('node:sqlite');
88
const { suite, it } = require('node:test');
99

10-
suite('DatabaseSync verbose option', () => {
10+
suite('DatabaseSync trace option', () => {
1111
it('callback receives SQL string for exec() statements', (t) => {
1212
const calls = [];
1313
const db = new DatabaseSync(':memory:', {
14-
verbose: (sql) => calls.push(sql),
14+
trace: (sql) => calls.push(sql),
1515
});
1616

1717
db.exec('CREATE TABLE t (x INTEGER)');
@@ -26,7 +26,7 @@ suite('DatabaseSync verbose option', () => {
2626
it('callback receives SQL string for prepared statement execution', (t) => {
2727
let calls = [];
2828
const db = new DatabaseSync(':memory:', {
29-
verbose: (sql) => calls.push(sql),
29+
trace: (sql) => calls.push(sql),
3030
});
3131

3232
db.exec('CREATE TABLE t (x INTEGER)');
@@ -43,7 +43,7 @@ suite('DatabaseSync verbose option', () => {
4343
it('callback receives SQL string for SELECT statements', () => {
4444
let calls = [];
4545
const db = new DatabaseSync(':memory:', {
46-
verbose: (sql) => calls.push(sql),
46+
trace: (sql) => calls.push(sql),
4747
});
4848

4949
db.exec('CREATE TABLE t (x INTEGER)');
@@ -61,7 +61,7 @@ suite('DatabaseSync verbose option', () => {
6161
it('callback receives SQL string for UPDATE statements', () => {
6262
let calls = [];
6363
const db = new DatabaseSync(':memory:', {
64-
verbose: (sql) => calls.push(sql),
64+
trace: (sql) => calls.push(sql),
6565
});
6666

6767
db.exec('CREATE TABLE t (x INTEGER)');
@@ -79,7 +79,7 @@ suite('DatabaseSync verbose option', () => {
7979
it('callback receives SQL string for DELETE statements', () => {
8080
let calls = [];
8181
const db = new DatabaseSync(':memory:', {
82-
verbose: (sql) => calls.push(sql),
82+
trace: (sql) => calls.push(sql),
8383
});
8484

8585
db.exec('CREATE TABLE t (x INTEGER)');
@@ -98,7 +98,7 @@ suite('DatabaseSync verbose option', () => {
9898
let calls = [];
9999

100100
const db = new DatabaseSync(':memory:', {
101-
verbose: (sql) => calls.push(sql),
101+
trace: (sql) => calls.push(sql),
102102
limits: { length: 1000 },
103103
});
104104

@@ -116,19 +116,19 @@ suite('DatabaseSync verbose option', () => {
116116
db.close();
117117
});
118118

119-
it('invalid type for verbose throws ERR_INVALID_ARG_TYPE', () => {
119+
it('invalid type for trace throws ERR_INVALID_ARG_TYPE', () => {
120120
assert.throws(() => {
121-
new DatabaseSync(':memory:', { verbose: 'not-a-function' });
121+
new DatabaseSync(':memory:', { trace: 'not-a-function' });
122122
}, {
123123
code: 'ERR_INVALID_ARG_TYPE',
124-
message: /The "options\.verbose" argument must be a function\./,
124+
message: /The "options\.trace" argument must be a function\./,
125125
});
126126

127127
assert.throws(() => {
128-
new DatabaseSync(':memory:', { verbose: 42 });
128+
new DatabaseSync(':memory:', { trace: 42 });
129129
}, {
130130
code: 'ERR_INVALID_ARG_TYPE',
131-
message: /The "options\.verbose" argument must be a function\./,
131+
message: /The "options\.trace" argument must be a function\./,
132132
});
133133
});
134134
});

0 commit comments

Comments
 (0)