Ready for merge

Removed residual code and comments.
Commented and explained staticSource
Removed modularBuild and tested test
This commit is contained in:
Heinrich 2023-11-18 13:27:22 +08:00 committed by Simon Binder
parent 7c2c17d5e4
commit 6bb34e0db1
3 changed files with 6 additions and 17 deletions

View File

@ -199,16 +199,6 @@ class DartViewResolver extends LocalElementResolver<DiscoveredDartView> {
(builder) => builder.addAstNode(body.expression, exclude: {target!}));
}
// if(resolver.driver.options.assumeCorrectReference){
// bool separate = false;
// for (int i = 0; i < query.elements.length; i++) {
// if (separate && query.elements[i] is String && i != query.elements.length-1) {
// query.elements[i]+=',';
// separate = false;
// }
// separate = query.elements[i] is DartTopLevelSymbol;
// }
// }
return _ParsedDartViewSelect(
resolvedFrom, innerJoins, outerJoins, columnExpressions, query, from);
}
@ -227,7 +217,7 @@ class DartViewResolver extends LocalElementResolver<DiscoveredDartView> {
if (parts.length > 1) {
final reference =
references.firstWhereOrNull((ref) => ref.name == parts[0]);
if (reference == null || reference.table == null) {
if (reference == null) {
reportError(DriftAnalysisError.inDartAst(
discovered.dartElement,
columnReference,

View File

@ -96,6 +96,11 @@ class DartViewSource extends DriftViewSource {
final AnnotatedDartCode dartQuerySource;
final TableReferenceInDartView? primaryFrom;
final List<TableReferenceInDartView> staticReferences;
/// `staticSource` is used when the view is unable to automatically detect the source table for the data.
/// In cases where the table source is not yet generated or is not directly detectable,
/// but the programmer knows the expected source, this field can be manually specified to
/// inform the view of the intended data source. **Requires the `assume_correct_reference` option to be true.**
final String? staticSource;
DartViewSource(this.dartQuerySource, this.primaryFrom, this.staticReferences, [this.staticSource]);
}

View File

@ -740,14 +740,10 @@ CREATE TABLE [STRING_TABLE](
);
''',
},
modularBuild: true,
options: BuilderOptions({'assume_correct_reference': true}),
logger: debugLogger
);
// var actual = utf8.decode(result.writer.assets[(result.writer.assets.keys
// .firstWhere((key) => key.path == ('lib/drift/datastore_db.drift.dart')))]!);
checkOutputs(
{
'a|lib/drift/datastore_db.drift.dart': decodedMatches(
@ -755,8 +751,6 @@ CREATE TABLE [STRING_TABLE](
contains(r'attachedDatabase.selectOnly(attachedDatabase.comboGroup)'),
),
),
'a|lib/drift/combo_group.drift.dart' : anything,
'a|lib/drift/string_table.drift.dart' : anything,
},
result.dartOutputs,
result.writer,