-
Notifications
You must be signed in to change notification settings - Fork 120
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
Can not load ToMany data content #655
Comments
Is this maybe because the If not, then the relation of "b" is not updated. I would welcome a simple example project to reproduce it. Anyhow, I strongly recommend to use a separate model for JSON and for ObjectBox and map between them. Otherwise, future changes may be difficult or impossible. Also: please don't post screenshots, post actual code. |
Also: I provided all of my code. You can copy and run. |
Oh, sorry I did not see the collapsed code block. I updated the description with the actual code that can be copied. I will have a look once I have time. Anyhow, my question is still valid. Including the note about model separation. |
The problem is that my model (not mock ones here) is built based on API so I need to parse from JSON here. |
Sure. But your project should then still have a separate model for the database. So one for JSON parsing and one for the database. Then map between those. |
The underlying issue is that the constructor for
This breaks the final cParam = obx.ToMany<C>();
final object = B(c: cParam)
..obId =
const fb.Int64Reader().vTableGetNullable(buffer, rootOffset, 4);
obx_int.InternalToManyAccess.setRelInfo<B>(
object.c, store, obx_int.RelInfo<B>.toMany(1, object.obId!));
return object; We might be able to change the generated code to call |
Thanks for your update. |
The above issue only exists when reading from a Box. The data is correctly put. Maybe you can change the model to provide a default, no arguments constructor that ObjectBox can use. Or as I said, do not use the same model for your network layer (JSON) and the database layer. |
Is there an existing issue?
No
Build info
Steps to reproduce
Just run this code:
Expected behavior
I want to get a list of "c" from "a".
Actual behavior
Get "c" from "a" is empty.
Code
Code
Logs, stack traces
TODO Add relevant logs, a stack trace or crash report.
Logs
[Paste your logs here]
The text was updated successfully, but these errors were encountered: