mirror of https://github.com/AMT-Cheif/drift.git
Add failing test for #447
This commit is contained in:
parent
5b675a811b
commit
2da8577b01
|
@ -10,13 +10,15 @@ class AnalyzeDartStep extends AnalyzingStep {
|
|||
for (final accessor in parseResult.dbAccessors) {
|
||||
final transitiveImports = _transitiveImports(accessor.imports);
|
||||
|
||||
var availableEntities = _availableEntities(transitiveImports)
|
||||
.followedBy(accessor.declaredTables)
|
||||
.toList();
|
||||
final unsortedEntities = _availableEntities(transitiveImports)
|
||||
.followedBy(accessor.declaredTables);
|
||||
List<MoorSchemaEntity> availableEntities;
|
||||
|
||||
try {
|
||||
availableEntities = sortEntitiesTopologically(availableEntities);
|
||||
availableEntities = sortEntitiesTopologically(unsortedEntities.toSet());
|
||||
} on CircularReferenceException catch (e) {
|
||||
// Just keep them unsorted so that we can generate some code
|
||||
availableEntities = unsortedEntities.toList();
|
||||
final msg = StringBuffer(
|
||||
'Found a circular reference in your database. This can cause '
|
||||
'exceptions at runtime when opening the database. This is the '
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
import 'package:moor_generator/src/analyzer/runner/results.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import '../utils.dart';
|
||||
|
||||
void main() {
|
||||
test("tables imported in two ways aren't duplicated", () async {
|
||||
final state = TestState.withContent({
|
||||
'foo|lib/main.dart': '''
|
||||
import 'package:moor/moor.dart';
|
||||
|
||||
import 'table.dart';
|
||||
|
||||
@UseMoor(tables: [Users], include: {'file.moor'})
|
||||
class MyDatabase {}
|
||||
''',
|
||||
'foo|lib/file.moor': '''
|
||||
import 'table.dart';
|
||||
''',
|
||||
'foo|lib/table.dart': '''
|
||||
import 'package:moor/moor.dart';
|
||||
|
||||
class Users extends Table {
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
}
|
||||
'''
|
||||
});
|
||||
|
||||
final dbFile = await state.analyze('package:foo/main.dart');
|
||||
final db =
|
||||
(dbFile.currentResult as ParsedDartFile).declaredDatabases.single;
|
||||
|
||||
expect(db.entities, hasLength(1));
|
||||
}, skip: 'https://github.com/simolus3/moor/issues/447');
|
||||
}
|
Loading…
Reference in New Issue