Skip to content

Bug: Array fields are not supported in Supabase replication (push fails with "unknown how to handle type: object") #8473

Description

@len360

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

  1. 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" }
		}
	}
}
  1. Insert a document:
await collection.insert({
  name: "Foo",
  skills: ["Teaching", "Summarizing"],
});
  1. Run replication

  2. Delete the document:

await doc.remove();
  1. 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}`)
        }
    }
    
    //...
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions