Skip to content

Commit

Permalink
docs: Add missing KDocs for exposed-dao InnerTableLink API
Browse files Browse the repository at this point in the history
Add KDocs in `exposed-dao` to files relating to InnerTableLink.
  • Loading branch information
bog-walk committed Mar 1, 2024
1 parent 46a32d3 commit 4fd9e89
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ import org.jetbrains.exposed.sql.transactions.TransactionManager
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty

/**
* Class responsible for implementing property delegates of the read-write properties involved in a many-to-many
* relation, which uses an intermediate (join) table.
*
* @param table The intermediate table containing reference columns to both child and parent entities.
* @param sourceTable The [IdTable] associated with the source child entity.
* @param target The [EntityClass] for the target parent entity.
* @param _sourceColumn The intermediate table's reference column for the child entity class. If left `null`,
* this will be inferred from the provided intermediate [table] columns.
* @param _targetColumn The intermediate table's reference column for the parent entity class. If left `null`,
* this will be inferred from the provided intermediate [table] columns.
*/
@Suppress("UNCHECKED_CAST")
class InnerTableLink<SID : Comparable<SID>, Source : Entity<SID>, ID : Comparable<ID>, Target : Entity<ID>>(
val table: Table,
Expand All @@ -35,10 +47,12 @@ class InnerTableLink<SID : Comparable<SID>, Source : Entity<SID>, ID : Comparabl
}
}

/** The reference identity column for the child entity class. */
val sourceColumn = _sourceColumn
?: table.columns.singleOrNull { it.referee == sourceTable.id } as? Column<EntityID<SID>>
?: error("Table does not reference source")

/** The reference identity column for the parent entity class. */
val targetColumn = _targetColumn
?: table.columns.singleOrNull { it.referee == target.table.id } as? Column<EntityID<ID>>
?: error("Table does not reference target")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ object EntityTestsData {

class YEntity(id: EntityID<String>) : Entity<String>(id) {
var x by YTable.x
val b by BEntity.backReferencedOn(XTable.y1)
val b: BEntity? by BEntity.backReferencedOn(XTable.y1)
var content by YTable.blob

companion object : EntityClass<String, YEntity>(YTable)
Expand Down

0 comments on commit 4fd9e89

Please sign in to comment.