Skip to content

Commit

Permalink
handle self referencing relations
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindberg committed Jun 16, 2023
1 parent c482d23 commit 40d9fe5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions typo/src/scala/typo/internal/ComputedTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ case class ComputedTable(
val source = Source.Table(dbTable.name)
val pointsTo: Map[db.ColName, (Source.Relation, db.ColName)] =
dbTable.foreignKeys.flatMap { fk =>
val otherTable: Lazy[HasSource] = eval(fk.otherTable)
val value = fk.otherCols.map(cn => (otherTable.forceGet.source, cn))
val otherTable: HasSource =
if (fk.otherTable == dbTable.name) this
else eval(fk.otherTable).forceGet(s"${dbTable.name.value} => ${fk.otherTable.value}")

val value = fk.otherCols.map(cn => (otherTable.source, cn))
fk.cols.zip(value).toList
}.toMap

Expand Down

0 comments on commit 40d9fe5

Please sign in to comment.