Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when updating a record with a hasMany relationship #10

Open
chsanch opened this issue Nov 11, 2022 · 0 comments
Open

Issue when updating a record with a hasMany relationship #10

chsanch opened this issue Nov 11, 2022 · 0 comments

Comments

@chsanch
Copy link

chsanch commented Nov 11, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant