Skip to content

Commit 809154b

Browse files
authored
Merge pull request #44 from elefeint/set_duckdb_api
Set duckdb_api to nodejs
2 parents d569cf7 + 8cb8dff commit 809154b

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/database.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct OpenTask : public Task {
3333
: Task(database_, callback_), filename(filename_) {
3434

3535
duckdb_config.options.access_mode = access_mode_;
36+
duckdb_config.SetOptionByName("duckdb_api", duckdb::Value("nodejs"));
3637
Napi::Env env = database_.Env();
3738
Napi::HandleScope scope(env);
3839

test/config.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import * as duckdb from '..';
2+
import * as assert from 'assert';
3+
import {TableData} from "..";
4+
5+
describe('user_agent', () => {
6+
7+
it('default value', (done) => {
8+
const db: duckdb.Database = new duckdb.Database(':memory:');
9+
10+
db.all('PRAGMA USER_AGENT', (err: null | Error, rows: TableData) => {
11+
if (err) {
12+
throw err;
13+
}
14+
assert.match(rows[0].user_agent, /duckdb\/.*\(*\) nodejs/);
15+
done();
16+
});
17+
})
18+
19+
it('with custom_user_agent', (done) => {
20+
const db: duckdb.Database = new duckdb.Database(':memory:', { 'custom_user_agent': 'a_framework' });
21+
22+
db.all('PRAGMA USER_AGENT', (err: null | Error, rows: TableData) => {
23+
if (err) {
24+
throw err;
25+
}
26+
assert.match(rows[0].user_agent, /duckdb\/.*\(*\) nodejs a_framework/);
27+
done();
28+
});
29+
})
30+
})

0 commit comments

Comments
 (0)