objectbox / objectbox-dart

Flutter database for super-fast Dart object persistence
https://docs.objectbox.io/getting-started
Apache License 2.0
927 stars 115 forks source link

[Generator] Imports in generated code conflict with common entity class names #519

Closed Asperson closed 3 months ago

Asperson commented 1 year ago

In my app I have entity named Condition and objectbox generator generates objectbox.g.dart with follow error:

The name 'Condition' is defined in the libraries 'package:myapp/model/condition.dart' and 'package:objectbox/src/native/query/query.dart'.

I wasn't able to find a way (like generator option) to resole that error other than rename my entity

Basic info:

Steps to reproduce

  1. In new flutter project create new entity class named Condition with just id field
  2. Run generator with command flutter pub run build_runner build --delete-conflicting-outputs
  3. If you excluded generated files in analysis_options.yaml you need to compile it to see error, otherwise you will see it right there.

Expected behavior

code generation without errors

greenrobot-team commented 1 year ago

Thanks for reporting! We'll see if we can get around this (e.g. rename the library classes to more unique names or alias the library imports with a prefix).

greenrobot-team commented 3 months ago

With the next release imports from the objectbox library will use an alias to make conflicts with entity classes less likely.