Skip to content

Commit e982dd2

Browse files
committed
sqlite: rename verbose to trace
1 parent 01f3e9a commit e982dd2

5 files changed

Lines changed: 26 additions & 28 deletions

File tree

doc/api/sqlite.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ added: v22.5.0
132132
changes:
133133
- version: REPLACEME
134134
pr-url: https://github.com/nodejs/node/pull/62241
135-
description: Add `verbose` option.
135+
description: Add `trace` option.
136136
- version:
137137
- v25.5.0
138138
- v24.14.0
@@ -206,7 +206,7 @@ changes:
206206
* `likePatternLength` {number} Maximum length of a LIKE pattern.
207207
* `variableNumber` {number} Maximum number of SQL variables.
208208
* `triggerDepth` {number} Maximum trigger recursion depth.
209-
* `verbose` {Function} An optional callback function that is invoked for
209+
* `trace` {Function} An optional callback function that is invoked for
210210
every SQL statement executed against the database. The callback receives
211211
the expanded SQL string (with bound parameter values substituted) as its
212212
only argument. If expansion fails, the source SQL (with unsubstituted
@@ -1662,8 +1662,8 @@ callback function to indicate what type of operation is being authorized.
16621662
[`sqlite3_prepare_v2()`]: https://www.sqlite.org/c3ref/prepare.html
16631663
[`sqlite3_serialize()`]: https://sqlite.org/c3ref/serialize.html
16641664
[`sqlite3_set_authorizer()`]: https://sqlite.org/c3ref/set_authorizer.html
1665-
[`sqlite3_trace_v2()`]: https://www.sqlite.org/c3ref/trace_v2.html
16661665
[`sqlite3_sql()`]: https://www.sqlite.org/c3ref/expanded_sql.html
1666+
[`sqlite3_trace_v2()`]: https://www.sqlite.org/c3ref/trace_v2.html
16671667
[`sqlite3changeset_apply()`]: https://www.sqlite.org/session/sqlite3changeset_apply.html
16681668
[`sqlite3session_attach()`]: https://www.sqlite.org/session/sqlite3session_attach.html
16691669
[`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
@@ -376,7 +376,7 @@
376376
V(url_string, "url") \
377377
V(username_string, "username") \
378378
V(value_string, "value") \
379-
V(verbose_string, "verbose") \
379+
V(trace_string, "trace") \
380380
V(verify_error_string, "verifyError") \
381381
V(version_string, "version") \
382382
V(windows_hide_string, "windowsHide") \

src/node_sqlite.cc

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

996996
{
997997
Local<Value> cb =
998-
object()->GetInternalField(kVerboseCallback).template As<Value>();
998+
object()->GetInternalField(kTraceCallback).template As<Value>();
999999
if (cb->IsFunction()) {
10001000
sqlite3_trace_v2(
10011001
connection_, SQLITE_TRACE_STMT, DatabaseSync::TraceCallback, this);
@@ -1368,21 +1368,19 @@ void DatabaseSync::New(const FunctionCallbackInfo<Value>& args) {
13681368
}
13691369
}
13701370

1371-
// Parse verbose option
1372-
Local<Value> verbose_v;
1373-
if (!options->Get(env->context(), env->verbose_string())
1374-
.ToLocal(&verbose_v)) {
1371+
// Parse trace option
1372+
Local<Value> trace_v;
1373+
if (!options->Get(env->context(), env->trace_string()).ToLocal(&trace_v)) {
13751374
return;
13761375
}
1377-
if (!verbose_v->IsUndefined() && !verbose_v->IsNull()) {
1378-
if (!verbose_v->IsFunction()) {
1376+
if (!trace_v->IsUndefined() && !trace_v->IsNull()) {
1377+
if (!trace_v->IsFunction()) {
13791378
THROW_ERR_INVALID_ARG_TYPE(
13801379
env->isolate(),
1381-
"The \"options.verbose\" argument must be a function.");
1380+
"The \"options.trace\" argument must be a function.");
13821381
return;
13831382
}
1384-
args.This()->SetInternalField(kVerboseCallback,
1385-
verbose_v.As<Function>());
1383+
args.This()->SetInternalField(kTraceCallback, trace_v.As<Function>());
13861384
}
13871385
}
13881386

@@ -2581,7 +2579,7 @@ int DatabaseSync::TraceCallback(unsigned int type,
25812579
Local<Context> context = env->context();
25822580

25832581
Local<Value> cb =
2584-
db->object()->GetInternalField(kVerboseCallback).template As<Value>();
2582+
db->object()->GetInternalField(kTraceCallback).template As<Value>();
25852583

25862584
if (!cb->IsFunction()) {
25872585
return 0;

src/node_sqlite.h

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

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)