withAttributes method

ProgramSectionQuery withAttributes()

Implementation

ProgramSectionQuery withAttributes() {
  final programSectionAttribute =
      Repository<ProgramSectionAttribute>(database: database as Database);
  final Column? relationColumn = programSectionAttribute.columns.firstWhere(
      (column) =>
          column.relation?.referencedEntity?.tableName == this.tableName);

  if (relationColumn != null) {
    ColumnRelation relation = ColumnRelation(
        referencedColumn: relationColumn.relation?.attributeName,
        attributeName: 'attributes',
        primaryKey: this.primaryKey?.name,
        relationType: RelationType.OneToMany,
        referencedEntity: Entity.getEntityDefinition(
            AnnotationReflectable.reflectType(ProgramSectionAttribute)
                as ClassMirror),
        referencedEntityColumns: Entity.getEntityColumns(
            AnnotationReflectable.reflectType(ProgramSectionAttribute)
                as ClassMirror,
            false));

    this.relations.add(relation);
  }

  return this;
}