Fix modular accessors sometimes not being generated

This commit is contained in:
Simon Binder 2022-12-07 21:27:45 +01:00
parent a3d755ca19
commit fb3d832f0f
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
1 changed files with 7 additions and 1 deletions

View File

@ -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