[Kotlin] Fix key lookup returning null clashing with default value (#7237)

* [Java] Fix key lookup returning null clashing with default value

A field with key attribute must always be written on the message so it
can be looked up by key. There is a edge case where inserting a key
field with same value as default would prevent it to be written on
the message and later cannot be found when searched by key.

* [Kotlin] Fix key lookup returning null clashing with default value

A field with key attribute must always be written on the message so it
can be looked up by key. There is a edge case where inserting a key
field with same value as default would prevent it to be written on
the message and later cannot be found when searched by key.

Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
Paulo Pinheiro
2022-04-12 02:17:19 +02:00
committed by GitHub
parent 7181d77700
commit 7b5fd2bd05
8 changed files with 211 additions and 13 deletions

View File

@@ -48,7 +48,10 @@ class Referrable : Table() {
return endReferrable(builder)
}
fun startReferrable(builder: FlatBufferBuilder) = builder.startTable(1)
fun addId(builder: FlatBufferBuilder, id: ULong) = builder.addLong(0, id.toLong(), 0)
fun addId(builder: FlatBufferBuilder, id: ULong) {
builder.addLong(id.toLong())
builder.slot(0)
}
fun endReferrable(builder: FlatBufferBuilder) : Int {
val o = builder.endTable()
return o