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,
|
||||
customParentClass: dataClassInfo.extending,
|
||||
entityInfoName: '\$${discovered.dartElement.name}View',
|
||||
source: DartViewSource(
|
||||
structure.dartQuerySource,
|
||||
structure.primarySource,
|
||||
staticReferences,
|
||||
structure.staticSource
|
||||
),
|
||||
source: DartViewSource(structure.dartQuerySource, structure.primarySource,
|
||||
staticReferences, structure.staticSource),
|
||||
references: [
|
||||
for (final reference in staticReferences) reference.table,
|
||||
],
|
||||
|
@ -179,7 +175,8 @@ class DartViewResolver extends LocalElementResolver<DiscoveredDartView> {
|
|||
final from = target.argumentList.arguments[0].toSource();
|
||||
final resolvedFrom =
|
||||
references.firstWhereOrNull((element) => element.name == from);
|
||||
if (resolvedFrom == null && !resolver.driver.options.assumeCorrectReference) {
|
||||
if (resolvedFrom == null &&
|
||||
!resolver.driver.options.assumeCorrectReference) {
|
||||
reportError(
|
||||
DriftAnalysisError.inDartAst(
|
||||
as,
|
||||
|
@ -192,8 +189,8 @@ class DartViewResolver extends LocalElementResolver<DiscoveredDartView> {
|
|||
AnnotatedDartCode query;
|
||||
if (resolvedFrom == null &&
|
||||
resolver.driver.options.assumeCorrectReference) {
|
||||
query = AnnotatedDartCode.build(
|
||||
(builder) => builder.addText(body.expression.toSource().replaceAll(target!.toSource(), '')));
|
||||
query = AnnotatedDartCode.build((builder) => builder.addText(
|
||||
body.expression.toSource().replaceAll(target!.toSource(), '')));
|
||||
} else {
|
||||
query = AnnotatedDartCode.build(
|
||||
(builder) => builder.addAstNode(body.expression, exclude: {target!}));
|
||||
|
@ -324,7 +321,8 @@ class _ParsedDartViewSelect {
|
|||
|
||||
final String? staticSource;
|
||||
_ParsedDartViewSelect(this.primarySource, this.innerJoins, this.outerJoins,
|
||||
this.selectedColumns, this.dartQuerySource, [this.staticSource]);
|
||||
this.selectedColumns, this.dartQuerySource,
|
||||
[this.staticSource]);
|
||||
|
||||
bool referenceIsNullable(TableReferenceInDartView 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
|
||||
/// 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]);
|
||||
DartViewSource(this.dartQuerySource, this.primaryFrom, this.staticReferences,
|
||||
[this.staticSource]);
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ class ElementSerializer {
|
|||
for (final reference in source.staticReferences)
|
||||
_serializeTableReferenceInDartView(reference),
|
||||
],
|
||||
'staticSource':source.staticSource
|
||||
'staticSource': source.staticSource
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -658,9 +658,9 @@ class ElementDeserializer {
|
|||
for (final element in serializedSource.list('staticReferences'))
|
||||
readReference(element as Map)
|
||||
],
|
||||
serializedSource['staticSource'] != null
|
||||
? serializedSource['staticSource'] as String
|
||||
: null,
|
||||
serializedSource['staticSource'] != null
|
||||
? serializedSource['staticSource'] as String
|
||||
: null,
|
||||
);
|
||||
} else {
|
||||
throw UnsupportedError('Unknown view source $serializedSource');
|
||||
|
|
|
@ -138,7 +138,8 @@ class ViewWriter extends TableOrViewWriter {
|
|||
final source = view.source;
|
||||
if (source is DartViewSource) {
|
||||
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))')
|
||||
..writeDart(source.dartQuerySource)
|
||||
..writeln(';');
|
||||
|
|
|
@ -741,14 +741,14 @@ CREATE TABLE [STRING_TABLE](
|
|||
''',
|
||||
},
|
||||
options: BuilderOptions({'assume_correct_reference': true}),
|
||||
logger: debugLogger
|
||||
);
|
||||
logger: debugLogger);
|
||||
|
||||
checkOutputs(
|
||||
{
|
||||
'a|lib/drift/datastore_db.drift.dart': decodedMatches(
|
||||
allOf(
|
||||
contains(r'attachedDatabase.selectOnly(attachedDatabase.comboGroup)'),
|
||||
contains(
|
||||
r'attachedDatabase.selectOnly(attachedDatabase.comboGroup)'),
|
||||
),
|
||||
),
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue