Unverified Commit cb6748ed authored by Hong Minhee's avatar Hong Minhee
Browse files

Fix double-quoted JSON values in the database

parent 330f9ae5
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -68,6 +68,14 @@ Changelog

To be released.

 -  Fixed a bug where JSON values are double-quoted in the database.  Since it's
    a breaking change data-wise, the default values of the following options
    are also changed:

     -  `PostgresKvStoreOptions.tableName` defaults to `"fedify_kv_v2"`.
     -  `PostgresMessageQueueOptions.tableName` defaults to
        `"fedify_message_v2"`.

### Version 0.1.0

Initial release.  Released on September 26, 2024.
+2 −2
Original line number Diff line number Diff line
@@ -8,11 +8,11 @@
    "./mq": "./src/mq.ts"
  },
  "imports": {
    "@deno/dnt": "jsr:@deno/dnt@^0.41.2",
    "@deno/dnt": "jsr:@deno/dnt@^0.41.3",
    "@fedify/fedify": "jsr:@fedify/fedify@^1.0.0",
    "@std/assert": "jsr:@std/assert@^0.226.0",
    "@std/async": "jsr:@std/async@^1.0.5",
    "postgres": "npm:postgres@^3.4.4"
    "postgres": "npm:postgres@^3.4.5"
  },
  "unstable": [
    "temporal"
+379 −403

File changed.

Preview size limit exceeded, changes collapsed.

+4 −4
Original line number Diff line number Diff line
@@ -22,13 +22,13 @@ Deno.test("PostgresKvStore", async (t) => {
  await t.step("get()", async () => {
    await sql`
      INSERT INTO ${sql(tableName)} (key, value)
      VALUES (${["foo", "bar"]}, ${'["foobar"]'})
      VALUES (${["foo", "bar"]}, ${["foobar"]})
    `;
    assertEquals(await store.get(["foo", "bar"]), ["foobar"]);

    await sql`
      INSERT INTO ${sql(tableName)} (key, value, ttl)
      VALUES (${["foo", "bar", "ttl"]}, ${'["foobar"]'}, ${"0 seconds"})
      VALUES (${["foo", "bar", "ttl"]}, ${["foobar"]}, ${"0 seconds"})
    `;
    await delay(500);
    assertEquals(await store.get(["foo", "bar", "ttl"]), undefined);
@@ -42,7 +42,7 @@ Deno.test("PostgresKvStore", async (t) => {
    `;
    assertEquals(result.length, 1);
    assertEquals(result[0].key, ["foo", "baz"]);
    assertEquals(result[0].value, '"baz"');
    assertEquals(result[0].value, "baz");
    assertEquals(result[0].ttl, null);

    await store.set(["foo", "qux"], "qux", {
@@ -54,7 +54,7 @@ Deno.test("PostgresKvStore", async (t) => {
    `;
    assertEquals(result2.length, 1);
    assertEquals(result2[0].key, ["foo", "qux"]);
    assertEquals(result2[0].value, '"qux"');
    assertEquals(result2[0].value, "qux");
    assertEquals(result2[0].ttl, "1 day");
  });

+6 −5

File changed.

Preview size limit exceeded, changes collapsed.

Loading