-
Notifications
You must be signed in to change notification settings - Fork 693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: EXPOSED-320 Many-to-many relation with extra columns #2204
Open
bog-walk
wants to merge
5
commits into
main
Choose a base branch
from
bog-walk/fix-many-to-many-composite
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c27defa
feat!: EXPOSED-320 Many-to-many relation with extra columns
bog-walk 41d9a75
feat!: EXPOSED-320 Many-to-many relation with extra columns
bog-walk 8adc0aa
feat!: EXPOSED-320 Many-to-many relation with extra columns
bog-walk a99b3f3
feat!: EXPOSED-320 Many-to-many relation with extra columns
bog-walk 0562b39
feat!: EXPOSED-320 Many-to-many relation with extra columns
bog-walk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -337,14 +337,19 @@ open class Entity<ID : Comparable<ID>>(val id: EntityID<ID>) { | |
* | ||
* @param sourceColumn The intermediate table's reference column for the child entity class. | ||
* @param targetColumn The intermediate table's reference column for the parent entity class. | ||
* @param additionalColumns Any additional columns from the intermediate table that should be included when inserting. | ||
* If left `null`, all columns additional to the [sourceColumn] and [targetColumn] will be included in the insert | ||
* statement and will require a value if defaults are not defined. Provide an empty list as an argument if all | ||
* additional columns should be ignored. | ||
* @sample org.jetbrains.exposed.sql.tests.shared.entities.ViaTests.NodesTable | ||
* @sample org.jetbrains.exposed.sql.tests.shared.entities.ViaTests.Node | ||
* @sample org.jetbrains.exposed.sql.tests.shared.entities.ViaTests.NodeToNodes | ||
*/ | ||
fun <TID : Comparable<TID>, Target : Entity<TID>> EntityClass<TID, Target>.via( | ||
sourceColumn: Column<EntityID<ID>>, | ||
targetColumn: Column<EntityID<TID>> | ||
) = InnerTableLink(sourceColumn.table, [email protected], this@via, sourceColumn, targetColumn) | ||
targetColumn: Column<EntityID<TID>>, | ||
additionalColumns: List<Column<*>>? = null | ||
) = InnerTableLink(sourceColumn.table, [email protected], this@via, sourceColumn, targetColumn, additionalColumns) | ||
|
||
/** | ||
* Deletes this [Entity] instance, both from the cache and from the database. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most ideally, there should be a cache that stores the link entities without any relation to their referenced counterparts, solely based on some special id, which could be retrieved from the
ResultRow
inwrapLinkRow()
. This is how thedata
cache is for example set up for all regular entities.This would mean either a brand new id for the entity (defeats the purpose as the point is to not introduce a new/fake id column in the intermediate table, since uniqueness is based on the 2 referencing columns) or some way to check
ResultRow
values against entity values. For the latter, I did consider forcing another override where the user defines some sort of equality match betweenResultRow
andInnerTableLinkEntity
, but it got a bit messy.What the above cache does is store all
InnerTableLinkEntity
s for a target column and source (column) id, so uniqueness essentially relies on 3 values: target column (e.g.task
inProjectTasks
), source id (e.g.project
value inProjectTasks
), and target id (e.g.TaskWithData.id
stored in the entity itself).