Skip to content

Commit

Permalink
Use explicit-typed binding
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Nov 18, 2024
1 parent 6f9624d commit 9b20ddc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ Changelog

To be released.

- Use the explicitly typed binding instead of an implicit one to work
around the stringification issue.

### Version 0.2.1

Released on November 3, 2024.
Expand Down
4 changes: 2 additions & 2 deletions src/kv.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { KvKey, KvStore, KvStoreSetOptions } from "@fedify/fedify";
import type { Sql } from "postgres";
import type { JSONValue, Sql } from "postgres";

/**
* Options for the PostgreSQL key-value store.
Expand Down Expand Up @@ -84,7 +84,7 @@ export class PostgresKvStore implements KvStore {
INSERT INTO ${this.#sql(this.#tableName)} (key, value, ttl)
VALUES (
${key},
(${{ value } as unknown as string}::jsonb) -> 'value',
${this.#sql.json(value as JSONValue)},
${ttl}
)
ON CONFLICT (key)
Expand Down
2 changes: 1 addition & 1 deletion src/mq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class PostgresMessageQueue implements MessageQueue {
await this.#sql`
INSERT INTO ${this.#sql(this.#tableName)} (message, delay)
VALUES (
(${{ message } as unknown as string}::jsonb) -> 'message',
${this.#sql.json(message)},
${delay.toString()}
);
`;
Expand Down

0 comments on commit 9b20ddc

Please sign in to comment.