Skip to content

Issue when updating a record with a hasMany relationship #10

@chsanch

Description

@chsanch

I have a model profile with a hasMany relationship to a Enrolment model, it works fine when I retrieve the profile data with the enrolments records, but when I tried to update the Profile record, I’m getting this error:

code: "42703"
details: null
hint: null
message: "column _.enrolments does not exist"

As a workaround I've added this code to the Application serializer:

export default class ApplicationSerializer extends SupabaseSerializer {
  serialize(snapshot, options) {
    let json = super.serialize(...arguments);
    snapshot.eachRelationship((key, relationship) => {
      if (relationship.kind === 'hasMany') {
        delete json[key];
      }
    });
    return json;
  }
}

I think it would worthy to add this as the default behaviour, as it seems Supabase doesn't handle the relationship field send by the Serializer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions