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 2, 2024
1 parent 46a32d3 commit 2c5b091
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ abstract class EntityClass<ID : Comparable<ID>, out T : Entity<ID>>(
* @sample org.jetbrains.exposed.sql.tests.shared.entities.EntityTests.Parent
* @sample org.jetbrains.exposed.sql.tests.shared.entities.EntityTests.Children
* @sample org.jetbrains.exposed.sql.tests.shared.entities.EntityTests.Child
*
*/
infix fun <REF : Comparable<REF>> referencedOn(column: Column<REF>) = registerRefRule(column) { Reference(column, this) }

Expand Down
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 @@ -20,7 +20,7 @@ private fun checkReference(reference: Column<*>, factoryTable: IdTable<*>) {
}

/**
* Class representing a table relation between 2 [Entity] classes, which is responsible for
* Class representing a table relation between two [Entity] classes, which is responsible for
* retrieving the parent entity referenced by the child entity.
*
* @param reference The reference column defined on the child entity's associated table.
Expand All @@ -36,7 +36,7 @@ class Reference<REF : Comparable<REF>, ID : Comparable<ID>, out Target : Entity<
}

/**
* Class representing an optional table relation between 2 [Entity] classes, which is responsible for
* Class representing an optional table relation between two [Entity] classes, which is responsible for
* retrieving the parent entity optionally referenced by the child entity.
*
* @param reference The nullable reference column defined on the child entity's associated table.
Expand All @@ -53,7 +53,7 @@ class OptionalReference<REF : Comparable<REF>, ID : Comparable<ID>, out Target :

/**
* Class responsible for implementing property delegates of the read-only properties involved in a table
* relation between 2 [Entity] classes, which retrieves the child entity that references the parent entity.
* relation between two [Entity] classes, which retrieves the child entity that references the parent entity.
*
* @param reference The reference column defined on the child entity's associated table.
* @param factory The [EntityClass] associated with the child entity that references the parent entity.
Expand All @@ -70,7 +70,7 @@ internal class BackReference<ParentID : Comparable<ParentID>, out Parent : Entit

/**
* Class responsible for implementing property delegates of the read-only properties involved in an optional table
* relation between 2 [Entity] classes, which retrieves the child entity that optionally references the parent entity.
* relation between two [Entity] classes, which retrieves the child entity that optionally references the parent entity.
*
* @param reference The nullable reference column defined on the child entity's associated table.
* @param factory The [EntityClass] associated with the child entity that optionally references the parent entity.
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 2c5b091

Please sign in to comment.