Skip to content

Commit

Permalink
add tests for arrays/records in field names that need quoting
Browse files Browse the repository at this point in the history
  • Loading branch information
mtoy-googly-moogly committed Nov 29, 2024
1 parent 609bde0 commit 16521b4
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/src/databases/all/compound-atomic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,22 @@ describe.each(runtimes.runtimeList)(
{roll: 8, rolls: 1},
]);
});
test('array stored field with special chars in name', async () => {
const special_chars = ["'", '"', '.', '`'];
for (const c of special_chars) {
const qname = '`_\\' + c + '_`';
const malloySrc = `
run: ${empty}
->{ select: ${qname} is [1]}
-> { select: num is ${qname}.each }`;
const result = await runtime.loadQuery(malloySrc).run();
const ok =
result.data.path(0, 'num').value === 1
? 'ok'
: `Array containing ${c} character is not ok`;
expect(ok).toEqual('ok');
}
});
test.when(supportsNestedArrays)('bare array of array', async () => {
await expect(`
run: ${empty} -> { select: aoa is [[1,2]] }
Expand Down Expand Up @@ -226,6 +242,22 @@ describe.each(runtimes.runtimeList)(
expect(p).toEqual('ok');
}
});
test('record stored in field with special chars in name', async () => {
const special_chars = ["'", '"', '.', '`'];
for (const c of special_chars) {
const qname = '`_\\' + c + '_`';
const malloySrc = `
run: ${empty}
->{ select: ${qname} is {rnum is 1}}
-> { select: num is ${qname}.rnum }`;
const result = await runtime.loadQuery(malloySrc).run();
const ok =
result.data.path(0, 'num').value === 1
? 'ok'
: `Array containing ${c} character is not ok`;
expect(ok).toEqual('ok');
}
});
test.when(canReadCompoundSchema)(
'can read schema of record object',
async () => {
Expand Down

0 comments on commit 16521b4

Please sign in to comment.