From fb3d832f0f4b145dc197e35cb75629f4fb6f38be Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 7 Dec 2022 21:27:45 +0100 Subject: [PATCH] Fix modular accessors sometimes not being generated --- drift_dev/lib/src/analysis/driver/state.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drift_dev/lib/src/analysis/driver/state.dart b/drift_dev/lib/src/analysis/driver/state.dart index 3d3a98b7..398e4933 100644 --- a/drift_dev/lib/src/analysis/driver/state.dart +++ b/drift_dev/lib/src/analysis/driver/state.dart @@ -3,6 +3,7 @@ import 'package:meta/meta.dart'; import 'package:path/path.dart' show url; import 'package:sqlparser/sqlparser.dart' hide AnalysisError; +import '../resolver/intermediate_state.dart'; import '../results/database.dart'; import '../results/element.dart'; import '../results/file_results.dart'; @@ -62,7 +63,12 @@ class FileState { } bool get _definesQuery { - return analyzedElements.any((e) => e is DefinedSqlQuery); + return analyzedElements.any((e) => e is DefinedSqlQuery) || + // Also check discovery, we might not have analyzed all elements in this + // file if it's just an import. + discovery?.locallyDefinedElements + .any((e) => e is DiscoveredDriftStatement) == + true; } /// Whether an accessor class making queries and imports available should be