You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I call session.id = await sessionBean.upsert(session, cascade: true) on a new session, I get the following error:
[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The getter 'id' was called on null.
Receiver: null
Tried calling: id
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1 _StudentSessionBean.attach (package:tablet_app/models/student_session.jorm.dart:473:25)
#2 _SessionBean.upsert (package:tablet_app/models/session.jorm.dart:202:36)
And so right, the session object doesn't have an id yet. attach can only associate objects with ids. The cascade logic inside the generated upsert seems to assume the session already has an id set, so it will only work if upsert is used for updating, which kinda defeats the purpose of an upsert method.
Workaround: I can override upsert to call super.upsert twice, once without cascade:
I have a model with a many-to-many relationship:
When I call
session.id = await sessionBean.upsert(session, cascade: true)
on a new session, I get the following error:And so right, the
session
object doesn't have an id yet.attach
can only associate objects with ids. The cascade logic inside the generated upsert seems to assume thesession
already has an id set, so it will only work if upsert is used for updating, which kinda defeats the purpose of an upsert method.Workaround: I can override
upsert
to callsuper.upsert
twice, once without cascade:Versions:
The text was updated successfully, but these errors were encountered: