Description
When using Supabase replication, documents containing array fields (e.g. string[]) cause the push process to fail with the following error:
Error: unknown how to handle type: object
This issue occurs during update (patch) and delete operations, while insert operations work correctly.
Steps to reproduce
- Define a schema with an array field:
{
"title": "hero schema",
"version": 0,
"primaryKey": "name",
"type": "object",
"properties": {
"name": {
"type": "string",
"maxLength": 100
},
"skills": {
"type": "array",
items: { type: "string" }
}
}
}
- Insert a document:
await collection.insert({
name: "Foo",
skills: ["Teaching", "Summarizing"],
});
-
Run replication
-
Delete the document:
- Trigger replication
Location of the Issue
The issue appears to originate from the addDocEqualityToQuery function, where document fields are converted into query filters.
export function addDocEqualityToQuery<RxDocType>(
jsonSchema: RxJsonSchema<RxDocumentData<RxDocType>>,
deletedField: string,
modifiedField: string,
doc: WithDeleted<RxDocType>,
query: any
) {
// ....
for (const key of Object.keys(doc)) {
if (ignoreKeys.has(key)) {
continue;
}
const v = (doc as any)[key];
const type = typeof v;
if (type === "string" || type === "number") {
query = query.eq(key, v);
} else if (type === "boolean" || v === null) {
query = query.is(key, v);
} else if (type === 'undefined') {
query = query.is(key, null);
} else {
// Problem: arrays and JSON objects are not handled
throw new Error(`unknown how to handle type: ${type}`)
}
}
//...
}
Description
When using Supabase replication, documents containing array fields (e.g.
string[]) cause the push process to fail with the following error:This issue occurs during update (patch) and delete operations, while insert operations work correctly.
Steps to reproduce
Run replication
Delete the document:
Location of the Issue
The issue appears to originate from the
addDocEqualityToQueryfunction, where document fields are converted into query filters.