11import { constructAfterRecord } from '@module/utils/pgwire_utils.js' ;
22import * as pgwire from '@powersync/service-jpgwire' ;
3- import { SqliteRow } from '@powersync/service-sync-rules' ;
3+ import { CustomSqliteType , SqliteInputRow , SqliteRow , TimeValue } from '@powersync/service-sync-rules' ;
44import { describe , expect , test } from 'vitest' ;
55import { clearTestDb , connectPgPool , connectPgWire , TEST_URI } from './util.js' ;
66import { WalStream } from '@module/replication/WalStream.js' ;
@@ -159,8 +159,8 @@ VALUES(10, ARRAY['null']::TEXT[]);
159159 id : 3n ,
160160 date : '2023-03-06' ,
161161 time : '15:47:00' ,
162- timestamp : '2023-03-06 15:47:00' ,
163- timestamptz : '2023-03-06 13:47:00Z'
162+ timestamp : new TimeValue ( '2023-03-06 15:47:00' , '2023-03-06T15:47:00' ) ,
163+ timestamptz : new TimeValue ( '2023-03-06 13:47:00Z' , '2023-03-06T13:47:00Z' )
164164 } ) ;
165165
166166 expect ( transformed [ 3 ] ) . toMatchObject ( {
@@ -176,25 +176,25 @@ VALUES(10, ARRAY['null']::TEXT[]);
176176 id : 5n ,
177177 date : '0000-01-01' ,
178178 time : '00:00:00' ,
179- timestamp : '0000-01-01 00:00:00' ,
180- timestamptz : '0000-01-01 00:00:00Z'
179+ timestamp : new TimeValue ( '0000-01-01 00:00:00' , '0000-01-01T00:00:00' ) ,
180+ timestamptz : new TimeValue ( '0000-01-01 00:00:00Z' , '0000-01-01T00:00:00Z' )
181181 } ) ;
182182
183183 expect ( transformed [ 5 ] ) . toMatchObject ( {
184184 id : 6n ,
185- timestamp : '1970-01-01 00:00:00' ,
186- timestamptz : '1970-01-01 00:00:00Z'
185+ timestamp : new TimeValue ( '1970-01-01 00:00:00' , '1970-01-01T00:00:00' ) ,
186+ timestamptz : new TimeValue ( '1970-01-01 00:00:00Z' , '1970-01-01T00:00:00Z' )
187187 } ) ;
188188
189189 expect ( transformed [ 6 ] ) . toMatchObject ( {
190190 id : 7n ,
191- timestamp : '9999-12-31 23:59:59' ,
192- timestamptz : '9999-12-31 23:59:59Z'
191+ timestamp : new TimeValue ( '9999-12-31 23:59:59' , '9999-12-31T23:59:59' ) ,
192+ timestamptz : new TimeValue ( '9999-12-31 23:59:59Z' , '9999-12-31T23:59:59Z' )
193193 } ) ;
194194
195195 expect ( transformed [ 7 ] ) . toMatchObject ( {
196196 id : 8n ,
197- timestamptz : '0022-02-03 09:13:14Z'
197+ timestamptz : new TimeValue ( '0022-02-03 09:13:14Z' , '0022-02-03T09:13:14Z' )
198198 } ) ;
199199
200200 expect ( transformed [ 8 ] ) . toMatchObject ( {
@@ -235,8 +235,11 @@ VALUES(10, ARRAY['null']::TEXT[]);
235235 id : 3n ,
236236 date : `["2023-03-06"]` ,
237237 time : `["15:47:00"]` ,
238- timestamp : `["2023-03-06 15:47:00"]` ,
239- timestamptz : `["2023-03-06 13:47:00Z","2023-03-06 13:47:00.12345Z"]`
238+ timestamp : CustomSqliteType . wrapArray ( [ new TimeValue ( '2023-03-06 15:47:00' , '2023-03-06T15:47:00' ) ] ) ,
239+ timestamptz : CustomSqliteType . wrapArray ( [
240+ new TimeValue ( '2023-03-06 13:47:00Z' , '2023-03-06T13:47:00Z' ) ,
241+ new TimeValue ( '2023-03-06 13:47:00.12345Z' , '2023-03-06T13:47:00.12345Z' )
242+ ] )
240243 } ) ;
241244
242245 expect ( transformed [ 3 ] ) . toMatchObject ( {
@@ -436,7 +439,7 @@ VALUES(10, ARRAY['null']::TEXT[]);
436439 * Return all the inserts from the first transaction in the replication stream.
437440 */
438441async function getReplicationTx ( replicationStream : pgwire . ReplicationStream ) {
439- let transformed : SqliteRow [ ] = [ ] ;
442+ let transformed : SqliteInputRow [ ] = [ ] ;
440443 for await ( const batch of replicationStream . pgoutputDecode ( ) ) {
441444 for ( const msg of batch . messages ) {
442445 if ( msg . tag == 'insert' ) {
0 commit comments