Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Keys don't encode polymorphic type #50

Open
gnawf opened this issue Jan 8, 2022 · 0 comments
Open

Keys don't encode polymorphic type #50

gnawf opened this issue Jan 8, 2022 · 0 comments

Comments

@gnawf
Copy link

gnawf commented Jan 8, 2022

Say I had this polymorphic type

sealed interface SavedListElement : Metadata {}
class SavedWorkRef : SavedListElement {
  override val id: String
}
class SavedChapterRef : SavedListElement {
  override val id: String
}

and this definition

TypeTable {
    root<SavedListElement>()
        .sub<SavedWorkRef>()
        .sub<SavedChapterRef>()
}

Then I get

Screen Shot 2022-01-08 at 10 40 50 pm

Where the keys are the same for both concrete types as long as the ID is the same.

This means I can't store the store different types given the same key, is that normal? e.g.

val id = UUID.randomUUID().toString()
val a = SavedChapterRef(id)
val b = SavedWorkRef(id)
db.put(a)
println(db.getById<SavedWorkRef>(b.id))

Prints out

SavedChapterRef(id=56652680-31d2-4a13-81d9-5671e961f0ad)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant