mirror of https://github.com/AMT-Cheif/drift.git
Apply dart formatting
This commit is contained in:
parent
6bb34e0db1
commit
0029c44232
|
@ -30,12 +30,8 @@ class DartViewResolver extends LocalElementResolver<DiscoveredDartView> {
|
||||||
existingRowClass: dataClassInfo.existingClass,
|
existingRowClass: dataClassInfo.existingClass,
|
||||||
customParentClass: dataClassInfo.extending,
|
customParentClass: dataClassInfo.extending,
|
||||||
entityInfoName: '\$${discovered.dartElement.name}View',
|
entityInfoName: '\$${discovered.dartElement.name}View',
|
||||||
source: DartViewSource(
|
source: DartViewSource(structure.dartQuerySource, structure.primarySource,
|
||||||
structure.dartQuerySource,
|
staticReferences, structure.staticSource),
|
||||||
structure.primarySource,
|
|
||||||
staticReferences,
|
|
||||||
structure.staticSource
|
|
||||||
),
|
|
||||||
references: [
|
references: [
|
||||||
for (final reference in staticReferences) reference.table,
|
for (final reference in staticReferences) reference.table,
|
||||||
],
|
],
|
||||||
|
@ -179,7 +175,8 @@ class DartViewResolver extends LocalElementResolver<DiscoveredDartView> {
|
||||||
final from = target.argumentList.arguments[0].toSource();
|
final from = target.argumentList.arguments[0].toSource();
|
||||||
final resolvedFrom =
|
final resolvedFrom =
|
||||||
references.firstWhereOrNull((element) => element.name == from);
|
references.firstWhereOrNull((element) => element.name == from);
|
||||||
if (resolvedFrom == null && !resolver.driver.options.assumeCorrectReference) {
|
if (resolvedFrom == null &&
|
||||||
|
!resolver.driver.options.assumeCorrectReference) {
|
||||||
reportError(
|
reportError(
|
||||||
DriftAnalysisError.inDartAst(
|
DriftAnalysisError.inDartAst(
|
||||||
as,
|
as,
|
||||||
|
@ -192,8 +189,8 @@ class DartViewResolver extends LocalElementResolver<DiscoveredDartView> {
|
||||||
AnnotatedDartCode query;
|
AnnotatedDartCode query;
|
||||||
if (resolvedFrom == null &&
|
if (resolvedFrom == null &&
|
||||||
resolver.driver.options.assumeCorrectReference) {
|
resolver.driver.options.assumeCorrectReference) {
|
||||||
query = AnnotatedDartCode.build(
|
query = AnnotatedDartCode.build((builder) => builder.addText(
|
||||||
(builder) => builder.addText(body.expression.toSource().replaceAll(target!.toSource(), '')));
|
body.expression.toSource().replaceAll(target!.toSource(), '')));
|
||||||
} else {
|
} else {
|
||||||
query = AnnotatedDartCode.build(
|
query = AnnotatedDartCode.build(
|
||||||
(builder) => builder.addAstNode(body.expression, exclude: {target!}));
|
(builder) => builder.addAstNode(body.expression, exclude: {target!}));
|
||||||
|
@ -324,7 +321,8 @@ class _ParsedDartViewSelect {
|
||||||
|
|
||||||
final String? staticSource;
|
final String? staticSource;
|
||||||
_ParsedDartViewSelect(this.primarySource, this.innerJoins, this.outerJoins,
|
_ParsedDartViewSelect(this.primarySource, this.innerJoins, this.outerJoins,
|
||||||
this.selectedColumns, this.dartQuerySource, [this.staticSource]);
|
this.selectedColumns, this.dartQuerySource,
|
||||||
|
[this.staticSource]);
|
||||||
|
|
||||||
bool referenceIsNullable(TableReferenceInDartView ref) {
|
bool referenceIsNullable(TableReferenceInDartView ref) {
|
||||||
return ref != primarySource && !innerJoins.contains(ref);
|
return ref != primarySource && !innerJoins.contains(ref);
|
||||||
|
|
|
@ -102,5 +102,6 @@ class DartViewSource extends DriftViewSource {
|
||||||
/// but the programmer knows the expected source, this field can be manually specified to
|
/// 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.**
|
/// inform the view of the intended data source. **Requires the `assume_correct_reference` option to be true.**
|
||||||
final String? staticSource;
|
final String? staticSource;
|
||||||
DartViewSource(this.dartQuerySource, this.primaryFrom, this.staticReferences, [this.staticSource]);
|
DartViewSource(this.dartQuerySource, this.primaryFrom, this.staticReferences,
|
||||||
|
[this.staticSource]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ class ElementSerializer {
|
||||||
for (final reference in source.staticReferences)
|
for (final reference in source.staticReferences)
|
||||||
_serializeTableReferenceInDartView(reference),
|
_serializeTableReferenceInDartView(reference),
|
||||||
],
|
],
|
||||||
'staticSource':source.staticSource
|
'staticSource': source.staticSource
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,8 @@ class ViewWriter extends TableOrViewWriter {
|
||||||
final source = view.source;
|
final source = view.source;
|
||||||
if (source is DartViewSource) {
|
if (source is DartViewSource) {
|
||||||
emitter
|
emitter
|
||||||
..write('(attachedDatabase.selectOnly(${scope.options.assumeCorrectReference? source.primaryFrom?.name ?? source.staticSource:source.primaryFrom?.name})'
|
..write(
|
||||||
|
'(attachedDatabase.selectOnly(${scope.options.assumeCorrectReference ? source.primaryFrom?.name ?? source.staticSource : source.primaryFrom?.name})'
|
||||||
'..addColumns(\$columns))')
|
'..addColumns(\$columns))')
|
||||||
..writeDart(source.dartQuerySource)
|
..writeDart(source.dartQuerySource)
|
||||||
..writeln(';');
|
..writeln(';');
|
||||||
|
|
|
@ -741,14 +741,14 @@ CREATE TABLE [STRING_TABLE](
|
||||||
''',
|
''',
|
||||||
},
|
},
|
||||||
options: BuilderOptions({'assume_correct_reference': true}),
|
options: BuilderOptions({'assume_correct_reference': true}),
|
||||||
logger: debugLogger
|
logger: debugLogger);
|
||||||
);
|
|
||||||
|
|
||||||
checkOutputs(
|
checkOutputs(
|
||||||
{
|
{
|
||||||
'a|lib/drift/datastore_db.drift.dart': decodedMatches(
|
'a|lib/drift/datastore_db.drift.dart': decodedMatches(
|
||||||
allOf(
|
allOf(
|
||||||
contains(r'attachedDatabase.selectOnly(attachedDatabase.comboGroup)'),
|
contains(
|
||||||
|
r'attachedDatabase.selectOnly(attachedDatabase.comboGroup)'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue