Bug: Array fields are not supported in Supabase replication (push fails with "unknown how to handle type: object")
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 23.4k
- Forks
- 1.2k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 110
Description
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:
await doc.remove();
- 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}`)
}
}
//...
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the addDocEqualityToQuery function identified in the issue and trace how it builds filters for Supabase replication during update and delete operations. Reproduce the schema and document example, then verify that documents with array fields can be updated and deleted through replication without the unknown type error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- supabase, typescript
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 70/100