Skip to content

Commit 8a9fd21

Browse files
committed
Merge remote-tracking branch 'origin/main' into multi-processor
2 parents e3d15e9 + 5ac5345 commit 8a9fd21

4 files changed

Lines changed: 26 additions & 4 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/service-sync-rules': patch
3+
---
4+
5+
Validate `iif()` calls with the same three-argument arity used by the sync stream evaluator.

packages/jpgwire/src/certs.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import * as fs from 'fs/promises';
2-
import { resolve } from 'path';
2+
import * as path from 'path';
3+
import { fileURLToPath } from 'url';
34

45
export const DEFAULT_CERTS = await loadDefaultCertificates();
56

67
async function loadDefaultCertificates() {
7-
const dir = new URL('../ca', import.meta.url).pathname;
8+
const dir = path.join(path.dirname(fileURLToPath(import.meta.url)), '../ca');
89
const files = await fs.readdir(dir);
910
let sum = '';
1011
for (let file of files) {
1112
if (file.endsWith('.pem')) {
12-
sum += (await fs.readFile(resolve(dir, file), 'utf-8')) + '\n';
13+
sum += (await fs.readFile(path.resolve(dir, file), 'utf-8')) + '\n';
1314
}
1415
}
1516
return sum;

packages/sync-rules/src/sync_plan/expression.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export const supportedFunctions: Record<string, ArgumentCount> = {
143143
hex: 1,
144144
ifnull: { min: 2 },
145145
//if: { min: 2 },
146-
iif: { min: 2 },
146+
iif: 3,
147147
instr: 2,
148148
length: 1,
149149
// TODO: Establish defaults for case sensitivity, changing escape characters, ICU support.

packages/sync-rules/test/src/compiler/sqlite.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ describe('sqlite conversion', () => {
8585
]);
8686
});
8787

88+
test('iif requires exactly three args', () => {
89+
expect(translate('iif(1, 2)')[1]).toStrictEqual([
90+
{
91+
message: 'Expected at least 3 arguments',
92+
source: 'iif(1, 2)'
93+
}
94+
]);
95+
96+
expect(translate('iif(1, 2, 3, 4)')[1]).toStrictEqual([
97+
{
98+
message: 'Expected at most 3 arguments',
99+
source: 'iif(1, 2, 3, 4)'
100+
}
101+
]);
102+
});
103+
88104
test.skip('must be even', () => {
89105
expect(translate("json_object('foo')")[1]).toStrictEqual([
90106
{

0 commit comments

Comments
 (0)