Flutter-Apps-pty / drift

Drift is an easy to use, reactive, typesafe persistence library for Dart & Flutter.
https://drift.simonbinder.eu/
MIT License
0 stars 0 forks source link

drift package investigation #1

Open rf-westhuizen opened 1 year ago

rf-westhuizen commented 1 year ago

What causes the build_runner to fail:

Using test: "generates views from drift tables in live project"

error 1:

line 61, column 7 of package:a/drift/datastore/datastoredb.dart: Could not read views from @DriftDatabase annotation! Please make sure that all table classes exist. , 61 | class DatastoreDb extends $DatastoreDb with MScotchDb, MMssqlDb { | ^^^^^^^^^^^ '

error 2: D:\Github\drift\drift_dev\lib\src\backends\build\drift_builder.dart Could not format generated source. The generated code is probably invalid, and this is most likely a bug in drift_dev.

rf-westhuizen commented 11 months ago

D:\Github\drift\drift_dev\test\utils.dart:

5 steps used in the build process:

D:\Github\drift\drift_dev\lib\src\backends\build\analyzer.dart (line: 104)

    if (results.analysis.isNotEmpty) {
      for (final result in results.analysis.values) {
        for (final error in result.errorsDuringAnalysis) {
          log.warning(error.toString());
          hadWarnings = true;
        }
      }

a|lib/drift/datastore/datastore_db.dart -> This is the file that the DriftAnalyzer is struggling with....

error 1: Could not read views from @DriftDatabase annotation! Please make sure that all table classes exist.

I changed the annotation for the DatastoreDb class to the following, and resolved that error message:

OLD: @DriftDatabase( include: {'tables/tables.drift'}, views: dataStoreViews, )

TESTING CASE:
@DriftDatabase( include: {'tables/content.drift','tables/content_data.drift','tables/content_type.drift'}, views: [ContentDataStringView], )

adding the specific view to the views 'LIST' solved the problem where the views could not be read from @DriftDatabase

I get a format error:

Need to looking into drift_builder.dart and dart_formatter.dart: D:\Github\drift\drift_dev\lib\src\backends\build\drift_builder.dart D:\Pub\Cache\hosted\pub.dev\dart_style-2.3.3\lib\src\dart_formatter.dart

var code = output.toString();
try {
  code = DartFormatter().format(code);
} on FormatterException {
  log.warning('Could not format generated source. The generated code is '
      'probably invalid, and this is most likely a bug in drift_dev.');
}