Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/rude-paws-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@powersync/common': patch
'@powersync/node': patch
'@powersync/react': patch
'@powersync/react-native': patch
'@powersync/web': patch
---

Fix a warning about raw tables being used when they're not.
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,8 @@ The next upload iteration will be delayed.`);
}

private async legacyStreamingSyncIteration(signal: AbortSignal, resolvedOptions: RequiredPowerSyncConnectionOptions) {
if (resolvedOptions.serializedSchema?.raw_tables != null) {
const rawTables = resolvedOptions.serializedSchema?.raw_tables;
if (rawTables != null && rawTables.length) {
this.logger.warn('Raw tables require the Rust-based sync client. The JS client will ignore them.');
}

Expand Down
51 changes: 51 additions & 0 deletions packages/node/tests/sync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,57 @@ function defineSyncTests(impl: SyncClientImplementation) {

expect((await query.next()).value.rows._array).toStrictEqual([]);
});
} else {
mockSyncServiceTest('warns about raw tables', async ({ syncService }) => {
const customSchema = new Schema({});
customSchema.withRawTables({
lists: {
put: {
sql: 'INSERT OR REPLACE INTO lists (id, name) VALUES (?, ?)',
params: ['Id', { Column: 'name' }]
},
delete: {
sql: 'DELETE FROM lists WHERE id = ?',
params: ['Id']
}
}
});

const logger = createLogger('test', { logLevel: Logger.TRACE });
const logMessages: string[] = [];
(logger as any).invoke = (level, args) => {
console.log(...args);
logMessages.push(util.format(...args));
};

const powersync = await syncService.createDatabase({ schema: customSchema, logger });
powersync.connect(new TestConnector(), options);

await vi.waitFor(() => expect(syncService.connectedListeners).toHaveLength(1));
expect(logMessages).toEqual(
expect.arrayContaining([expect.stringContaining('Raw tables require the Rust-based sync client')])
);
});

mockSyncServiceTest(`does not warn about raw tables if they're not used`, async ({ syncService }) => {
// Regression test for https://github.com/powersync-ja/powersync-js/issues/672
const customSchema = new Schema({});

const logger = createLogger('test', { logLevel: Logger.TRACE });
const logMessages: string[] = [];
(logger as any).invoke = (level, args) => {
console.log(...args);
logMessages.push(util.format(...args));
};

const powersync = await syncService.createDatabase({ schema: customSchema, logger });
powersync.connect(new TestConnector(), options);

await vi.waitFor(() => expect(syncService.connectedListeners).toHaveLength(1));
expect(logMessages).not.toEqual(
expect.arrayContaining([expect.stringContaining('Raw tables require the Rust-based sync client')])
);
});
}
}

Expand Down