You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The generated file database.steps.dart does not include the necessary imports.
For example, consider the following table definition:
import'enum/status.dart';
classTodoItemsextendsTable {
IntColumnget id =>integer().autoIncrement()();
IntColumnget status =>intEnum<Status>().withDefault(Constant(Status.draft.value))();
}
The generated file database.steps.dart references the Status enum due to the withDefault method.
However, the file does not include the required import for Status. The same issue arise for the generated test files.
As a result, developers must manually edit the generated file to include the missing import after each make-migrations command. Which is inconvenient.
Proposed Solutions:
Introduce an option in drift_dev to specify a list of imports to be included in the generated file.
Use a .g.dart convention (e.g., database.steps.g.dart) for the actual generated code. The main file (e.g., database.steps.dart) would include necessary imports and delegate functionality to the .g.dart file.
Automatically detect required imports (idk if it's possible)
The text was updated successfully, but these errors were encountered:
Could you retry this with the latest drift_dev version (2.23.0, which I've released just a few days ago)?
This used to be a longstanding problem, but that version fixes it by dynamically resolving the constant. When you export the schema, we run the drift generator in memory and use that to create an isolate that will collect all the CREATE TABLE statements that drift would generate. Then we replace the Dart expression (e.g. Status.draft) with the actual value (e.g. just 0).
It's kind of complicated, but we should be hiding that away from you and I'm convinced it's the only sound approach: Schema exports are supposed to represent an immutable snapshot of your schema, but if we keep the Dart expression with an import, you could change the definition of Status and then alter the meaning of the existing snapshots.
The generated file
database.steps.dart
does not include the necessary imports.For example, consider the following table definition:
The generated file database.steps.dart references the Status enum due to the withDefault method.
However, the file does not include the required import for Status. The same issue arise for the generated test files.
As a result, developers must manually edit the generated file to include the missing import after each make-migrations command. Which is inconvenient.
Proposed Solutions:
The text was updated successfully, but these errors were encountered: