Skip to content
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

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

Closed
Asperson opened this issue Mar 13, 2023 · 2 comments
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Asperson
Copy link

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:

  • ObjectBox and ObjectBox generator version: 1.7.2
  • Flutter/Dart SDK: 3.7.7
  • Null-safety enabled: yes
  • Reproducibility: always
  • OS: Windows 11
  • Device/Emulator: Windows

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

@Asperson Asperson added the bug Something isn't working label Mar 13, 2023
@greenrobot-team
Copy link
Member

greenrobot-team commented Mar 13, 2023

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 greenrobot-team changed the title [Flutter][generator] Generated code has ambigous class references in some cases [Generator] Imports in generated code conflict with common entity class names May 9, 2023
@greenrobot-team greenrobot-team added this to the 2.4.1 milestone Feb 13, 2024
@greenrobot-team
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants