alias method

  1. @override
List<QualifiedTablename> alias(
  1. ChangeNotification notification
)
override

And we provide a helper method to alias changes in the form {attachedDbName, tablenames} to aliasedTablenames.

Implementation

@override
List<QualifiedTablename> alias(ChangeNotification notification) {
  final dbName = notification.dbName;
  final changes = notification.changes;
  final idx = attachedDbIndex;
  final primaryDbName = this.dbName;

  return changes
      .map((change) {
        final qualifiedTablename = change.qualifiedTablename;
        if (dbName == primaryDbName) {
          return qualifiedTablename;
        }

        final dbAlias = idx.byName[dbName];
        if (dbAlias != null) {
          return QualifiedTablename(dbAlias, qualifiedTablename.tablename);
        }
      })
      .nonNulls
      .toList();
}