mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
chore: bump version to 0.19.0-rc.3 and update JsonField handling for improved value parsing
This commit is contained in:
@@ -7,7 +7,7 @@ describe("[data] JsonField", async () => {
|
||||
const field = new JsonField("test");
|
||||
fieldTestSuite(bunTestRunner, JsonField, {
|
||||
defaultValue: { a: 1 },
|
||||
sampleValues: ["string", { test: 1 }, 1],
|
||||
//sampleValues: ["string", { test: 1 }, 1],
|
||||
schemaType: "text",
|
||||
});
|
||||
|
||||
@@ -33,9 +33,9 @@ describe("[data] JsonField", async () => {
|
||||
});
|
||||
|
||||
test("getValue", async () => {
|
||||
expect(field.getValue({ test: 1 }, "form")).toBe('{\n "test": 1\n}');
|
||||
expect(field.getValue("string", "form")).toBe('"string"');
|
||||
expect(field.getValue(1, "form")).toBe("1");
|
||||
expect(field.getValue({ test: 1 }, "form")).toEqual({ test: 1 });
|
||||
expect(field.getValue("string", "form")).toBe("string");
|
||||
expect(field.getValue(1, "form")).toBe(1);
|
||||
|
||||
expect(field.getValue('{"test":1}', "submit")).toEqual({ test: 1 });
|
||||
expect(field.getValue('"string"', "submit")).toBe("string");
|
||||
@@ -43,6 +43,5 @@ describe("[data] JsonField", async () => {
|
||||
|
||||
expect(field.getValue({ test: 1 }, "table")).toBe('{"test":1}');
|
||||
expect(field.getValue("string", "table")).toBe('"string"');
|
||||
expect(field.getValue(1, "form")).toBe("1");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
"bin": "./dist/cli/index.js",
|
||||
"version": "0.19.0-rc.2",
|
||||
"version": "0.19.0-rc.3",
|
||||
"description": "Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.",
|
||||
"homepage": "https://bknd.io",
|
||||
"repository": {
|
||||
|
||||
@@ -80,7 +80,11 @@ export class JsonField<Required extends true | false = false, TypeOverride = obj
|
||||
return value;
|
||||
}
|
||||
|
||||
return JSON.parse(value);
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
} catch (e) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
|
||||
Reference in New Issue
Block a user