Skip to content

Commit 80bfdf8

Browse files
committed
fix: split points
1 parent 71346ce commit 80bfdf8

2 files changed

Lines changed: 42 additions & 4 deletions

File tree

src/store/reducers/table/__test__/utils.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe('table utils', () => {
1616
test('prepareColumnValue handles nulls, params, escaped strings, json documents, dates and uuid values', () => {
1717
expect(prepareColumnValue({type: 'Utf8'} as never, null)).toBe('null');
1818
expect(prepareColumnValue({type: 'Int64'} as never, '$value')).toBe('$value');
19+
expect(prepareColumnValue({type: 'Utf8'} as never, '$value')).toBe('"$value"');
1920
expect(prepareColumnValue({type: 'Utf8'} as never, 'line\n"quoted"')).toBe(
2021
'"line\\u000a\\"quoted\\""',
2122
);
@@ -84,6 +85,38 @@ describe('table utils', () => {
8485
expect(query).toContain('TTL = Interval("P1DT1H") ON `createdAt`');
8586
});
8687

88+
test('buildCreateTableQuery quotes explicit split-point strings that start with dollar signs', () => {
89+
const query = buildCreateTableQuery({
90+
tableName: 'folder/orders',
91+
columns: [
92+
{
93+
name: 'tenant',
94+
type: 'Utf8',
95+
key: true,
96+
notNull: true,
97+
},
98+
],
99+
settings: {
100+
partitionsType: PartitionsType.Explicit,
101+
partitionsAtKeys: [
102+
[
103+
{
104+
id: 'split-point-1',
105+
name: 'tenant',
106+
type: 'Utf8',
107+
key: true,
108+
notNull: true,
109+
isDefined: true,
110+
value: '$tenant',
111+
},
112+
],
113+
],
114+
},
115+
});
116+
117+
expect(query).toContain('PARTITION_AT_KEYS = (("$tenant"))');
118+
});
119+
87120
test('prepareYdbCreateQueryColumns ignores hidden defaults for key and autoincrement columns', () => {
88121
expect(
89122
prepareYdbCreateQueryColumns([

src/store/reducers/table/utils.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ export function prepareColumnValue(column: Column, value: string | null) {
9494
return 'null';
9595
}
9696

97-
if (value.startsWith('$')) {
98-
return value;
99-
}
100-
10197
switch (column.type) {
10298
case 'String':
10399
case 'Utf8':
@@ -106,6 +102,15 @@ export function prepareColumnValue(column: Column, value: string | null) {
106102
}
107103
case 'JsonDocument':
108104
return `JsonDocument(${prepareStringLiteralValue(value)})`;
105+
default:
106+
break;
107+
}
108+
109+
if (value.startsWith('$')) {
110+
return value;
111+
}
112+
113+
switch (column.type) {
109114
case 'Date':
110115
case 'Date32':
111116
case 'Datetime':

0 commit comments

Comments
 (0)