@@ -695,85 +695,104 @@ class NewSyncIntegrationTest : BaseSyncIntegrationTest(true) {
695695
696696 @Test
697697 @OptIn(ExperimentalPowerSyncAPI ::class , LegacySyncImplementation ::class )
698- fun rawTables () = databaseTest(createInitialDatabase = false ) {
699- val db = openDatabase(Schema (listOf (
700- RawTable (
701- name = " lists" ,
702- put = PendingStatement (
703- " INSERT OR REPLACE INTO lists (id, name) VALUES (?, ?)" ,
704- listOf (PendingStatementParameter .Id , PendingStatementParameter .Column (" name" ))
705- ),
706- delete = PendingStatement (
707- " DELETE FROM lists WHERE id = ?" , listOf (PendingStatementParameter .Id )
708- )
709- )
710- )))
711-
712- db.execute(" CREATE TABLE lists (id TEXT NOT NULL PRIMARY KEY, name TEXT)" )
713- turbineScope(timeout = 10.0 .seconds) {
714- val query = db.watch(" SELECT * FROM lists" , throttleMs = 0L ) {
715- it.getString(0 ) to it.getString(1 )
716- }.testIn(this )
717- query.awaitItem() shouldBe emptyList()
718-
719- db.connect(connector, options = options)
720- syncLines.send(SyncLine .FullCheckpoint (Checkpoint (
721- lastOpId = " 1" ,
722- checksums = listOf (BucketChecksum (" a" , checksum = 0 )),
723- )))
724- syncLines.send(
725- SyncLine .SyncDataBucket (
726- bucket = " a" ,
727- data =
698+ fun rawTables () =
699+ databaseTest(createInitialDatabase = false ) {
700+ val db =
701+ openDatabase(
702+ Schema (
728703 listOf (
729- OplogEntry (
730- checksum = 0L ,
731- data =
732- JsonUtil .json.encodeToString(
733- mapOf (
734- " name" to " custom list" ,
735- ),
704+ RawTable (
705+ name = " lists" ,
706+ put =
707+ PendingStatement (
708+ " INSERT OR REPLACE INTO lists (id, name) VALUES (?, ?)" ,
709+ listOf (PendingStatementParameter .Id , PendingStatementParameter .Column (" name" )),
710+ ),
711+ delete =
712+ PendingStatement (
713+ " DELETE FROM lists WHERE id = ?" ,
714+ listOf (PendingStatementParameter .Id ),
736715 ),
737- op = OpType .PUT ,
738- opId = " 1" ,
739- rowId = " my_list" ,
740- rowType = " lists" ,
741716 ),
742717 ),
743- after = null ,
744- nextAfter = null ,
745- ),
746- )
747- syncLines.send(SyncLine .CheckpointComplete (" 1" ))
748-
749- query.awaitItem() shouldBe listOf (" my_list" to " custom list" )
718+ ),
719+ )
750720
751- syncLines.send(SyncLine .FullCheckpoint (Checkpoint (
752- lastOpId = " 2" ,
753- checksums = listOf (BucketChecksum (" a" , checksum = 0 )),
754- )))
755- syncLines.send(
756- SyncLine .SyncDataBucket (
757- bucket = " a" ,
758- data =
759- listOf (
760- OplogEntry (
761- checksum = 0L ,
762- data = null ,
763- op = OpType .REMOVE ,
764- opId = " 2" ,
765- rowId = " my_list" ,
766- rowType = " lists" ,
721+ db.execute(" CREATE TABLE lists (id TEXT NOT NULL PRIMARY KEY, name TEXT)" )
722+ turbineScope(timeout = 10.0 .seconds) {
723+ val query =
724+ db
725+ .watch(" SELECT * FROM lists" , throttleMs = 0L ) {
726+ it.getString(0 ) to it.getString(1 )
727+ }.testIn(this )
728+ query.awaitItem() shouldBe emptyList()
729+
730+ db.connect(connector, options = options)
731+ syncLines.send(
732+ SyncLine .FullCheckpoint (
733+ Checkpoint (
734+ lastOpId = " 1" ,
735+ checksums = listOf (BucketChecksum (" a" , checksum = 0 )),
736+ ),
737+ ),
738+ )
739+ syncLines.send(
740+ SyncLine .SyncDataBucket (
741+ bucket = " a" ,
742+ data =
743+ listOf (
744+ OplogEntry (
745+ checksum = 0L ,
746+ data =
747+ JsonUtil .json.encodeToString(
748+ mapOf (
749+ " name" to " custom list" ,
750+ ),
751+ ),
752+ op = OpType .PUT ,
753+ opId = " 1" ,
754+ rowId = " my_list" ,
755+ rowType = " lists" ,
756+ ),
767757 ),
758+ after = null ,
759+ nextAfter = null ,
760+ ),
761+ )
762+ syncLines.send(SyncLine .CheckpointComplete (" 1" ))
763+
764+ query.awaitItem() shouldBe listOf (" my_list" to " custom list" )
765+
766+ syncLines.send(
767+ SyncLine .FullCheckpoint (
768+ Checkpoint (
769+ lastOpId = " 2" ,
770+ checksums = listOf (BucketChecksum (" a" , checksum = 0 )),
768771 ),
769- after = null ,
770- nextAfter = null ,
771- ),
772- )
773- syncLines.send(SyncLine .CheckpointComplete (" 1" ))
772+ ),
773+ )
774+ syncLines.send(
775+ SyncLine .SyncDataBucket (
776+ bucket = " a" ,
777+ data =
778+ listOf (
779+ OplogEntry (
780+ checksum = 0L ,
781+ data = null ,
782+ op = OpType .REMOVE ,
783+ opId = " 2" ,
784+ rowId = " my_list" ,
785+ rowType = " lists" ,
786+ ),
787+ ),
788+ after = null ,
789+ nextAfter = null ,
790+ ),
791+ )
792+ syncLines.send(SyncLine .CheckpointComplete (" 1" ))
774793
775- query.awaitItem() shouldBe emptyList()
776- query.cancelAndIgnoreRemainingEvents()
794+ query.awaitItem() shouldBe emptyList()
795+ query.cancelAndIgnoreRemainingEvents()
796+ }
777797 }
778- }
779798}
0 commit comments