Fixed
Status Update
Comments
ma...@mark43.com <ma...@mark43.com> #2
Comment has been deleted.
el...@google.com <el...@google.com> #3
Thank you for reporting this issue. We have added a fix and will have it included in the next release.
el...@google.com <el...@google.com>
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-main
commit 6aa7e7e786298cad202cda711e05d514cf50fe30
Author: elifbilgin <elifbilgin@google.com>
Date: Tue Oct 17 15:32:45 2023
Resolving DAO function default value issue.
In generated code, when an EntityCursorConverter is generated, the default value for columns of type Double were incorrectly being set to 0, instead of 0.0. This has been fixed in this CL. A fix for potential issues with Float have also been handled.
Bug: 304584179
Test: DaoKotlinCodegenTest.kt
Change-Id: Id75f51766f8bb98caf899a61358557d8488c3631
M room/room-compiler/src/main/kotlin/androidx/room/ext/xpoet_ext.kt
M room/room-compiler/src/test/kotlin/androidx/room/writer/DaoKotlinCodeGenTest.kt
M room/room-compiler/src/test/test-data/kotlinCodeGen/rawQuery.kt
https://android-review.googlesource.com/2795178
Branch: androidx-main
commit 6aa7e7e786298cad202cda711e05d514cf50fe30
Author: elifbilgin <elifbilgin@google.com>
Date: Tue Oct 17 15:32:45 2023
Resolving DAO function default value issue.
In generated code, when an EntityCursorConverter is generated, the default value for columns of type Double were incorrectly being set to 0, instead of 0.0. This has been fixed in this CL. A fix for potential issues with Float have also been handled.
Bug: 304584179
Test: DaoKotlinCodegenTest.kt
Change-Id: Id75f51766f8bb98caf899a61358557d8488c3631
M room/room-compiler/src/main/kotlin/androidx/room/ext/xpoet_ext.kt
M room/room-compiler/src/test/kotlin/androidx/room/writer/DaoKotlinCodeGenTest.kt
M room/room-compiler/src/test/test-data/kotlinCodeGen/rawQuery.kt
pr...@google.com <pr...@google.com> #5
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.room:room-compiler:2.6.1
Description
Version used:"2.6.0-rc01"
Devices/Android versions reproduced on: Not related
Kotlin implementation of DAO for @RawQuery function implementation with return type Double is initailised with 0 instead of 0.0 on null check.
@Entity
class Test(@PrimaryKey val d: Double, val l: Long) {
@Dao
interface TestDao {
@RawQuery
fun getLocation(query: SupportSQLiteQuery): Test
}
}
For this setup Room generates the following implementation:
private fun __entityCursorConverter_comTest(cursor: Cursor): Test {
val _entity: Test
val _cursorIndexOfD: Int = getColumnIndex(cursor, "d")
val _cursorIndexOfL: Int = getColumnIndex(cursor, "l")
val _tmpD: Double
if (_cursorIndexOfD == -1) {
_tmpD = 0 //Error: The integer literal does not conform to the expected type Double
} else {
_tmpD = cursor.getDouble(_cursorIndexOfD)
}
val _tmpL: Long
if (_cursorIndexOfL == -1) {
_tmpL = 0
} else {
_tmpL = cursor.getLong(_cursorIndexOfL)
}
_entity = Test(_tmpD,_tmpL)
return _entity
}