Skip to content

Commit 3f3da61

Browse files
committed
Add postgres test with reduced precision
1 parent 783622d commit 3f3da61

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

modules/module-postgres/test/src/pg_test.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
SqliteInputRow,
66
DateTimeValue,
77
TimeValue,
8-
CompatibilityEdition
8+
CompatibilityEdition,
9+
TimeValuePrecision
910
} from '@powersync/service-sync-rules';
1011
import { describe, expect, test } from 'vitest';
1112
import { clearTestDb, connectPgPool, connectPgWire, TEST_URI } from './util.js';
@@ -467,6 +468,19 @@ INSERT INTO test_data(id, time, timestamp, timestamptz) VALUES (1, '17:42:01.12'
467468
timestamp: '2023-03-06T15:47:12.400000',
468469
timestamptz: '2023-03-06T13:47:00.000000Z'
469470
});
471+
472+
const reducedPrecisionFormat = applyRowContext(
473+
row,
474+
new CompatibilityContext({
475+
edition: CompatibilityEdition.SYNC_STREAMS,
476+
maxTimeValuePrecision: TimeValuePrecision.milliseconds
477+
})
478+
);
479+
expect(reducedPrecisionFormat).toMatchObject({
480+
time: '17:42:01.120',
481+
timestamp: '2023-03-06T15:47:12.400',
482+
timestamptz: '2023-03-06T13:47:00.000Z'
483+
});
470484
} finally {
471485
await db.end();
472486
}

0 commit comments

Comments
 (0)