@@ -92,7 +92,7 @@ void _syncTests<T>({
9292
9393 List <Object ?> pushSyncData (
9494 String bucket, String opId, String rowId, Object op, Object ? data,
95- {int checksum = 0 }) {
95+ {int checksum = 0 , String objectType = 'items' }) {
9696 return syncLine ({
9797 'data' : {
9898 'bucket' : bucket,
@@ -103,7 +103,7 @@ void _syncTests<T>({
103103 {
104104 'op_id' : opId,
105105 'op' : op,
106- 'object_type' : 'items' ,
106+ 'object_type' : objectType ,
107107 'object_id' : rowId,
108108 'checksum' : checksum,
109109 'data' : json.encode (data),
@@ -676,6 +676,72 @@ void _syncTests<T>({
676676 expect (db.select ('SELECT * FROM ps_buckets' ), isEmpty);
677677 });
678678 });
679+
680+ group ('raw tables' , () {
681+ syncTest ('smoke test' , (_) {
682+ db.execute (
683+ 'CREATE TABLE users (id TEXT NOT NULL PRIMARY KEY, name TEXT NOT NULL) STRICT;' );
684+
685+ invokeControl (
686+ 'start' ,
687+ json.encode ({
688+ 'schema' : {
689+ 'tables' : [
690+ {
691+ 'name' : 'users' ,
692+ 'raw' : {
693+ 'put' : {
694+ 'sql' :
695+ 'INSERT OR REPLACE INTO users (id, name) VALUES (?, ?);' ,
696+ 'params' : [
697+ 'Id' ,
698+ {'Column' : 'name' }
699+ ],
700+ },
701+ 'delete' : {
702+ 'sql' : 'DELETE FROM users WHERE id = ?' ,
703+ 'params' : ['Id' ],
704+ },
705+ },
706+ 'columns' : [],
707+ }
708+ ],
709+ },
710+ }),
711+ );
712+
713+ // Insert
714+ pushCheckpoint (buckets: [bucketDescription ('a' )]);
715+ pushSyncData (
716+ 'a' ,
717+ '1' ,
718+ 'my_user' ,
719+ 'PUT' ,
720+ {'name' : 'First user' },
721+ objectType: 'users' ,
722+ );
723+ pushCheckpointComplete ();
724+
725+ final users = db.select ('SELECT * FROM users;' );
726+ expect (users, [
727+ {'id' : 'my_user' , 'name' : 'First user' }
728+ ]);
729+
730+ // Delete
731+ pushCheckpoint (buckets: [bucketDescription ('a' )]);
732+ pushSyncData (
733+ 'a' ,
734+ '1' ,
735+ 'my_user' ,
736+ 'REMOVE' ,
737+ null ,
738+ objectType: 'users' ,
739+ );
740+ pushCheckpointComplete ();
741+
742+ expect (db.select ('SELECT * FROM users' ), isEmpty);
743+ });
744+ });
679745}
680746
681747const _schema = {
0 commit comments