mirror of
https://github.com/olehomelchenko/astrolabe.git
synced 2026-08-08 02:02:33 +00:00
Chart builder: escape ./[/] in built field names
This commit is contained in:
@@ -674,6 +674,20 @@ describe('buildChartSpec', () => {
|
||||
expect((spec.mark as { type: string }).type).toBe(mark);
|
||||
}
|
||||
});
|
||||
|
||||
it('escapes `.`/`[`/`]` in encoded field names so they read as literal columns', () => {
|
||||
const spec = buildChartSpec({
|
||||
datasetName: 'D',
|
||||
mark: 'point',
|
||||
encodings: {
|
||||
x: { field: 'user.age', type: 'quantitative' },
|
||||
y: { field: 'cols[0]', type: 'quantitative' },
|
||||
},
|
||||
});
|
||||
const enc = spec.encoding as Record<string, { field: string }>;
|
||||
expect(enc.x.field).toBe('user\\.age');
|
||||
expect(enc.y.field).toBe('cols\\[0\\]');
|
||||
});
|
||||
});
|
||||
|
||||
describe('transforms — aggregate / bin / timeUnit', () => {
|
||||
@@ -940,6 +954,13 @@ describe('buildTransforms (predicate coercion + shape)', () => {
|
||||
expect(t).toEqual([{ filter: 'datum.value > 0' }]);
|
||||
});
|
||||
|
||||
it('escapes `.`/`[`/`]` in a predicate field so it reads as a literal column', () => {
|
||||
const t = buildTransforms(
|
||||
withFilters(filter({ field: 'user.age', fieldType: 'quantitative', op: 'gt', value: '10' })),
|
||||
);
|
||||
expect(t).toEqual([{ filter: { field: 'user\\.age', gt: 10 } }]);
|
||||
});
|
||||
|
||||
it('skips incomplete entries (blank value, blank range bound, blank expression)', () => {
|
||||
const t = buildTransforms(
|
||||
withFilters(
|
||||
|
||||
Reference in New Issue
Block a user