Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register Extension Functions After Export #565

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
var binaryDb = FS.readFile(this.filename, { encoding: "binary" });
this.handleError(sqlite3_open(this.filename, apiTemp));
this.db = getValue(apiTemp, "i32");
registerExtensionFunctions(this.db);
return binaryDb;
};

Expand Down
3 changes: 3 additions & 0 deletions test/test_extension_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ exports.test = function(sql, assert) {
var res = db.exec("SELECT reverse(str_data) FROM test;");
assert.equal(res[0]['values'][0][0], "!dlroW olleH", "reverse() function works");

db.export()
var res = db.exec("SELECT floor(4.1)");
assert.equal(res[0]['values'][0][0], 4, "extension function works after export()");
};

if (module == require.main) {
Expand Down
Loading