Skip to content

[BUG] Create a store with the specified name UniqueViolationException  #175

@Errechydy

Description

@Errechydy

What is the bug?

The create method says "Does nothing if the store already exists." but it doesn't.
Putting await FMTCStore('mapStore').manage.create(); in the main method which means executed each time the app stared will trigger UniqueViolationException, the first time everything will work find because the store name hasn't been created yet, but when you refresh the app the following exception occurs.
UniqueViolationException (ObjectBoxException: object put failed: Unique constraint for ObjectBoxStore.name would be violated by putting object with ID 2 because same property value already exists in object with ID 1)

How can we reproduce it?

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  Object? initErr;
  try {
    await FMTCObjectBoxBackend().initialise();
   await FMTCStore('mapStore').manage.create();
  } catch (err) {
    initErr = err;
    print("Error initialising FMTC: $err");
  }
// .......
  }

Do you have a potential solution?

No

Platforms

macOS 15.1

Severity

Fatal: Causes the application to crash

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue reports broken functionality or another error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions