companions flag shouldn't depend on data classes flag

This commit is contained in:
Alexander Wilde 2023-01-01 17:42:31 +00:00
parent 132d53fbb8
commit 624c145cfd
2 changed files with 9 additions and 8 deletions

View File

@ -25,12 +25,14 @@ class UpdateCompanionWriter {
String get _companionClass => _emitter.companionType(table).toString();
String get _companionType => _emitter.dartCode(_emitter.companionType(table));
void write() {
final rowClass = _emitter.dartCode(_emitter.rowType(table));
String get _rowType => scope.generationOptions.writeDataClasses
? _emitter.dartCode(_emitter.rowType(table))
: 'dynamic';
void write() {
_buffer.write('class $_companionClass '
'extends '
'${_emitter.drift('UpdateCompanion')}<$rowClass> {\n');
'${_emitter.drift('UpdateCompanion')}<$_rowType> {\n');
_writeFields();
_writeConstructor();
@ -124,10 +126,9 @@ class UpdateCompanionWriter {
? 'createCustom'
: 'custom';
final rowType = _emitter.dartCode(_emitter.rowType(table));
_buffer
..write(
'static ${_emitter.drift('Insertable')}<$rowType> $constructorName')
'static ${_emitter.drift('Insertable')}<$_rowType> $constructorName')
..write('({');
final expression = _emitter.drift('Expression');

View File

@ -206,20 +206,20 @@ class MyRow {
checkOutputs(
{
'a|lib/a.drift.dart': decodedMatches(contains('''
i1.Selectable<i0.MyRow> foo() {
i0.Selectable<i1.MyRow> foo() {
return customSelect(
'SELECT name,"otherUser"."id" AS "nested_0.id", "otherUser"."name" AS "nested_0.name" FROM users INNER JOIN users AS otherUser ON otherUser.id = users.id + 1',
variables: [],
readsFrom: {
users,
}).asyncMap((i1.QueryRow row) async => i0.MyRow(
}).asyncMap((i0.QueryRow row) async => i1.MyRow(
row.read<String>('name'),
otherUser: await users.mapFromRow(row, tablePrefix: 'nested_0'),
nested: await customSelect('SELECT id FROM users',
variables: [],
readsFrom: {
users,
}).map((i1.QueryRow row) => row.read<int>('id')).get(),
}).map((i0.QueryRow row) => row.read<int>('id')).get(),
));
}
'''))