Skip to content

Commit c96b12e

Browse files
committed
Fix passing JSON parameters
1 parent b9c45e5 commit c96b12e

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

packages/jpgwire/src/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ export function timestamptzToSqlite(source?: string): TimeValue | null {
258258
return null;
259259
}
260260

261-
const baseValue = parsed.toISOString().replace('.000', '').replace('Z', '');
262-
const baseText = `${baseValue}${precision ?? ''}Z`;
261+
const baseValue = parsed.toISOString().replace('Z', '');
262+
const baseText = `${baseValue}Z`;
263263

264264
return new TimeValue(baseText);
265265
}

packages/sync-rules/src/types.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { BucketPriority } from './BucketDescription.js';
88
import { ParameterLookup } from './BucketParameterQuerier.js';
99
import { TimeValue } from './types/time.js';
1010
import { CustomSqliteValue } from './types/custom_sqlite_value.js';
11+
import { CompatibilityContext } from './quirks.js';
1112

1213
export interface SyncRules {
1314
evaluateRow(options: EvaluateRowOptions): EvaluationResult[];
@@ -146,12 +147,14 @@ export class RequestParameters implements ParameterValueSet {
146147
user_id: tokenPayload.sub
147148
};
148149

149-
this.tokenParameters = toSyncRulesParameters(tokenParameters);
150+
// Client and token parameters don't contain DateTime values or other custom types, so we don't need to consider
151+
// compatibility.
152+
this.tokenParameters = toSyncRulesParameters(tokenParameters, CompatibilityContext.FULL_BACKWARDS_COMPATIBILITY);
150153
this.userId = tokenPayload.sub;
151154
this.rawTokenPayload = JSONBig.stringify(tokenPayload);
152155

153156
this.rawUserParameters = JSONBig.stringify(clientParameters);
154-
this.userParameters = toSyncRulesParameters(clientParameters!);
157+
this.userParameters = toSyncRulesParameters(clientParameters!, CompatibilityContext.FULL_BACKWARDS_COMPATIBILITY);
155158
this.streamParameters = null;
156159
this.rawStreamParameters = null;
157160
}

packages/sync-rules/src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ export function toSyncRulesRow(row: DatabaseInputRow): SqliteInputRow {
123123
*
124124
* @param parameters Generic JSON input
125125
*/
126-
export function toSyncRulesParameters(parameters: Record<string, any>): SqliteJsonRow {
126+
export function toSyncRulesParameters(parameters: Record<string, any>, context: CompatibilityContext): SqliteJsonRow {
127127
let record: SqliteJsonRow = {};
128128
for (let key of Object.keys(parameters)) {
129-
record[key] = toSyncRulesValue(parameters[key], true, false) as SqliteJsonValue;
129+
record[key] = applyValueContext(toSyncRulesValue(parameters[key], true, false), context) as SqliteJsonValue;
130130
}
131131
return record;
132132
}

0 commit comments

Comments
 (0)