Skip to content

Commit

Permalink
feat(zero-cache): support pg UUIDs, replicated as strings (#3420)
Browse files Browse the repository at this point in the history
  • Loading branch information
darkgnotic authored Dec 19, 2024
1 parent 9c120fd commit 6d360ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ describe('change-source/pg/end-to-mid-test', () => {
time TIME,
json JSON,
jsonb JSONB,
numz ENUMZ
numz ENUMZ,
uuid UUID
);
-- Use the internal zero schema to test tables in a different schema,
Expand Down Expand Up @@ -753,9 +754,9 @@ describe('change-source/pg/end-to-mid-test', () => {
'data types',
`
ALTER PUBLICATION zero_some_public SET TABLE foo (
id, int, big, flt, bool, timea, date, json, jsonb, numz);
id, int, big, flt, bool, timea, date, json, jsonb, numz, uuid);
INSERT INTO foo (id, int, big, flt, bool, timea, date, json, jsonb, numz)
INSERT INTO foo (id, int, big, flt, bool, timea, date, json, jsonb, numz, uuid)
VALUES (
'abc',
-2,
Expand All @@ -766,7 +767,8 @@ describe('change-source/pg/end-to-mid-test', () => {
'April 12, 2003',
'[{"foo":"bar","bar":"foo"},123]',
'{"far": 456, "boo" : {"baz": 123}}',
'2'
'2',
'A0EEBC99-9C0B-4EF8-BB6D-6BB9BD380A11'
);
`,
[
Expand All @@ -778,6 +780,7 @@ describe('change-source/pg/end-to-mid-test', () => {
{tag: 'add-column'},
{tag: 'add-column'},
{tag: 'add-column'},
{tag: 'add-column'},
{
tag: 'insert',
new: {
Expand All @@ -790,6 +793,7 @@ describe('change-source/pg/end-to-mid-test', () => {
json: [{foo: 'bar', bar: 'foo'}, 123],
jsonb: {boo: {baz: 123}, far: 456},
numz: '2',
uuid: 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11',
},
},
],
Expand All @@ -806,6 +810,7 @@ describe('change-source/pg/end-to-mid-test', () => {
json: '[{"foo":"bar","bar":"foo"},123]',
jsonb: '{"boo":{"baz":123},"far":456}',
numz: '2', // Verifies TEXT affinity
uuid: 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11',
['_0_version']: expect.stringMatching(/[a-z0-9]+/),
},
],
Expand Down Expand Up @@ -884,6 +889,13 @@ describe('change-source/pg/end-to-mid-test', () => {
notNull: false,
pos: 11,
},
uuid: {
characterMaximumLength: null,
dataType: 'uuid',
dflt: null,
notNull: false,
pos: 12,
},
['_0_version']: {
characterMaximumLength: null,
dataType: 'TEXT',
Expand Down
1 change: 1 addition & 0 deletions packages/zero-cache/src/types/lite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export function dataTypeToZqlValueType(
case 'character':
case 'character varying':
case 'text':
case 'uuid':
case 'varchar':
return 'string';

Expand Down

0 comments on commit 6d360ed

Please sign in to comment.