objectbox-dart icon indicating copy to clipboard operation
objectbox-dart copied to clipboard

[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: ObjectBoxException: failed to create store: 10501 Property price (3, Double) of entity Product is not compatible to its previous definition. Check its type.

Open vinodh013 opened this issue 2 years ago • 1 comments

@Entity(uid: 7376825570504103358)
class Invoice {
  int id;
  DateTime date = DateTime.now();
  ToMany<Product> products = ToMany<Product>();
  double total;


  Invoice({
    this.id = 0,
    required this.date,
    required this.products,
    required this.total,
    });
}```

vinodh013 avatar Jul 31 '22 18:07 vinodh013

@vinodh013 Can you please share more details? E.g. use the issue template as a guideline:

Start with a clear and concise problem description in English. Then provide the following information, please.

Basic info (please complete the following information):

  • ObjectBox version: [e.g. 0.14.0]
  • Flutter/Dart SDK: [e.g. 2.0.0, or the output of dart --version or flutter --version]
  • Null-safety enabled: [yes | no]
  • Reproducibility: [e.g. occurred once only | occasionally without visible pattern | always]
  • OS: [e.g. Linux 5.10.23 | Windows 10 | macOs BigSur | Android 10 | ... ]
  • Device/Emulator: [e.g. Galaxy S20]

Additionally, you can choose to provide more details, e.g. the output of:

  • pub deps --no-dev
  • flutter doctor -v

Steps to reproduce

  1. Put '...'
  2. Make changes to '....'
  3. See error

Expected behavior

A clear and concise description of what you expected to happen.

Code

If applicable, add code to help explain your problem.

  • Include your pubspec.yaml.
  • Include affected entity classes.
  • Please remove any unnecessary or confidential parts.
  • At best, link to or attach a project with a failing test.

Logs, stack traces

If applicable, add relevant logs, or a stack trace.

Additional context

Add any other context about the problem here.

  • Is there anything special about your app?
  • May transactions or multi-threading play a role?
  • Did you find any workarounds to prevent the issue?

Anyhow, the error message indicates that you have changed the type of a property after creating the database. This is not supported. If you are still in development, just delete the database file on your test device. If not, then either

  • choose a different name or
  • annotate the property with @Property(uid: 0), run the generator, then copy and paste the UID from [Change/reset] to create a new property with the same name and discarding the old data. https://docs.objectbox.io/advanced/data-model-updates#how-to-and-example-1

greenrobot-team avatar Aug 01 '22 06:08 greenrobot-team

Without additional information, we are unfortunately not sure how to resolve this issue. Therefore this issue has been automatically closed. Feel free to comment with additional details and we can re-open this issue.

github-actions[bot] avatar Aug 23 '22 02:08 github-actions[bot]