-
Notifications
You must be signed in to change notification settings - Fork 354
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
Code generation creates database table with wrong type #3034
Comments
I've had this issue with other code generation tools too. |
The db table name is
Please let me know if you need more information. |
@simolus3 It seems that this is not related to the manager API. Could you post the table spec, something reproducible will make it much easier to fix this. |
Yea I tried disabling
This is an example of the db table in the drift file, and I forgot to mention that
this class has some checks in the constructor, has a serializer not sure if these would be relevant.. |
Tell me if this is what is happening endpoints.drift
endpoints.dart class Endpoint{
// ...
} db.dart import 'package:drift/drift.dart';
import 'package:app/endpoints.dart' as location;
part 'db.g.dart';
@DriftDatabase(
include: {'endpoints.drift'},
)
class AppDb extends _$AppDb {
AppDb() : super(_openConnection());
@override
int get schemaVersion => 1;
} db.g.dart //... Generated Code
class Endpoints extends Table with TableInfo<Endpoints, location.Endpoint> {
// ...
}
//... More Generated Code The bug is that we should be using Is the above correct? |
yes. Sorry I could have been more clear. Thanks for your help. One difference from my actual code is that |
Ok I get the same problem when I made As long as that |
@simolus3 |
No worries! This is actually a known problem and a side-effect from trying to be more reliable about finding import aliases. It fixed some cases and made some others worse :( The problem is that we want drift-generated code to automatically be able to use import aliases (since it inherits those as it is a One way to fix this is to use modular code generation. It requires a few changes to your code, but reliably fixes this problem as drift can then generate its own files with imports and we avoid having to guess prefixes. |
Describe the bug
I have a class, let's say
x
that I use in dart. I also have a table in drift that's also namedx
. in the database.dart file, I uselocal.x
and justx
to refer to the database table.It used to be fine until last December or so, but when I regenerated code this week, the database table code is generated with
local.x
.Thank you in advance for your help!
The text was updated successfully, but these errors were encountered: