aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-08-04 18:53:54 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-08-04 18:54:08 -0700
commit637a38f394704eaea29b503a69d554b5726d6214 (patch)
tree288cbd30b0bbf97d95ebf20939a6cb6eb0b4bcee
parent190ba6b74380f4e92cea9e38ecce63cbcb7002b4 (diff)
downloadbun-637a38f394704eaea29b503a69d554b5726d6214.tar.gz
bun-637a38f394704eaea29b503a69d554b5726d6214.tar.zst
bun-637a38f394704eaea29b503a69d554b5726d6214.zip
Fixes #3991
Fixes #3991
-rw-r--r--src/bun.js/bindings/sqlite/JSSQLStatement.cpp8
-rw-r--r--test/js/bun/sqlite/sqlite.test.js36
2 files changed, 40 insertions, 4 deletions
diff --git a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp
index d42f01019..8519cb2e2 100644
--- a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp
+++ b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp
@@ -1107,11 +1107,11 @@ static inline JSC::JSValue constructResultObject(JSC::JSGlobalObject* lexicalGlo
if (len > 64) {
value = JSC::JSValue::decode(Bun__encoding__toStringUTF8(text, len, lexicalGlobalObject));
- continue;
+ break;
+ } else {
+ value = jsString(vm, WTF::String::fromUTF8(text, len));
+ break;
}
-
- value = jsString(vm, WTF::String::fromUTF8(text, len));
- break;
}
case SQLITE_BLOB: {
size_t len = sqlite3_column_bytes(stmt, i);
diff --git a/test/js/bun/sqlite/sqlite.test.js b/test/js/bun/sqlite/sqlite.test.js
index e4725cac2..7998f7469 100644
--- a/test/js/bun/sqlite/sqlite.test.js
+++ b/test/js/bun/sqlite/sqlite.test.js
@@ -553,3 +553,39 @@ describe("Database.run", () => {
}
});
});
+
+it("#3991", () => {
+ const db = new Database(":memory:");
+ db.prepare(
+ `CREATE TABLE IF NOT EXISTS users (
+ id TEXT PRIMARY KEY,
+ xx TEXT)
+`,
+ ).run();
+
+ db.prepare(
+ `insert into users (id, xx) values (
+ 'foobar',
+ '{
+ "links": [{"1": {
+ "2": "https://foobar.to/123",
+ "3": "4"
+ }}]
+
+ }'
+)`,
+ ).run();
+
+ let x = db
+ .query(
+ `SELECT * FROM users
+ WHERE users.id = 'foobar'
+ limit 1`,
+ )
+ .get();
+
+ // Check we don't crash when a column with a string value greater than 64 characters is present.
+ expect(x.abc).toBeUndefined();
+
+ expect(x.id).toBe("foobar");
+});