File tree 4 files changed +22
-2
lines changed
4 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,9 @@ Changelog
68
68
69
69
To be released.
70
70
71
+ - Fixed a bug where some scalar values have failed to be stored in the
72
+ database.
73
+
71
74
### Version 0.2.0
72
75
73
76
Released on November 3, 2024.
Original file line number Diff line number Diff line change @@ -56,6 +56,16 @@ Deno.test("PostgresKvStore", async (t) => {
56
56
assertEquals ( result2 [ 0 ] . key , [ "foo" , "qux" ] ) ;
57
57
assertEquals ( result2 [ 0 ] . value , "qux" ) ;
58
58
assertEquals ( result2 [ 0 ] . ttl , "1 day" ) ;
59
+
60
+ await store . set ( [ "foo" , "quux" ] , true ) ;
61
+ const result3 = await sql `
62
+ SELECT * FROM ${ sql ( tableName ) }
63
+ WHERE key = ${ [ "foo" , "quux" ] }
64
+ ` ;
65
+ assertEquals ( result3 . length , 1 ) ;
66
+ assertEquals ( result3 [ 0 ] . key , [ "foo" , "quux" ] ) ;
67
+ assertEquals ( result3 [ 0 ] . value , true ) ;
68
+ assertEquals ( result3 [ 0 ] . ttl , null ) ;
59
69
} ) ;
60
70
61
71
await t . step ( "delete()" , async ( ) => {
Original file line number Diff line number Diff line change @@ -82,7 +82,11 @@ export class PostgresKvStore implements KvStore {
82
82
const ttl = options ?. ttl == null ? null : options . ttl . toString ( ) ;
83
83
await this . #sql`
84
84
INSERT INTO ${ this . #sql( this . #tableName) } (key, value, ttl)
85
- VALUES (${ key } , ${ value as string } , ${ ttl } )
85
+ VALUES (
86
+ ${ key } ,
87
+ (${ { value } as unknown as string } ::jsonb) -> 'value',
88
+ ${ ttl }
89
+ )
86
90
ON CONFLICT (key)
87
91
DO UPDATE SET value = EXCLUDED.value, ttl = EXCLUDED.ttl;
88
92
` ;
Original file line number Diff line number Diff line change @@ -85,7 +85,10 @@ export class PostgresMessageQueue implements MessageQueue {
85
85
const delay = options ?. delay ?? Temporal . Duration . from ( { seconds : 0 } ) ;
86
86
await this . #sql`
87
87
INSERT INTO ${ this . #sql( this . #tableName) } (message, delay)
88
- VALUES (${ message } , ${ delay . toString ( ) } );
88
+ VALUES (
89
+ (${ { message } as unknown as string } ::jsonb) -> 'message',
90
+ ${ delay . toString ( ) }
91
+ );
89
92
` ;
90
93
await this . #sql. notify ( this . #channelName, delay . toString ( ) ) ;
91
94
}
You can’t perform that action at this time.
0 commit comments