Verified
Status Update
Comments
yb...@google.com <yb...@google.com> #2
Thanks for the thorough report - you're right about the problem, and the workaround looks good - it even handles the fast cases for initialization and setList(null) nicely.
Fix and tests submitted internally, should go out with next paging release.
Fix and tests submitted internally, should go out with next paging release.
je...@gmail.com <je...@gmail.com> #3
Actually, I'd like to know more about what failed here and why.
I'm curious if InstantTaskExecutorRule is putting paging into an unexpected state - do you have a sample project that reproduces the issue?
When hitting this outside of a test, are you specifying any custom executors, possibly ones which run main thread tasks immediately instead of posting them?
I'm curious if InstantTaskExecutorRule is putting paging into an unexpected state - do you have a sample project that reproduces the issue?
When hitting this outside of a test, are you specifying any custom executors, possibly ones which run main thread tasks immediately instead of posting them?
Description
Version used: 1.0.0-alpha1
Devices/Android versions reproduced on: n/a
*** ENTITY ***
@Entity(tableName = "individual")
class Individual constructor() {
@PrimaryKey(autoGenerate = true)
var id: Long = 0
@TypeConverters(DateLongConverter::class)
var lastModified: Date = Date()
}
*** DAO ***
@Dao
interface IndividualDao {
@Query("SELECT lastModified FROM individual WHERE id = :p0")
@TypeConverters(DateLongConverter::class)
fun findLastModified(p0: Long): Date
}
*** Converter ***
class DateLongConverter {
@TypeConverter
fun fromLongToDate(value: Long?): Date? {
value ?: return null
return Date().apply { time = value }
}
@TypeConverter
fun fromDateToLong(value: Date?) = return value?.time
}
*** Generated IndividualDao_Impl (snippit) ***
if(_cursor.moveToFirst()) {
final int _tmp;
_tmp = _cursor.getInt(0);
final String _tmp_1;
_tmp_1 = Integer.toString(_tmp);
final Long _tmp_2;
_tmp_2 = _tmp_1 == null ? null : Long.parseLong(_tmp_1);
_result = __dateLongConverter.fromLongToDate(_tmp_2);
}
The results for individualDao.findLastModified(1):
EXPECTED RESULTS: "Thu May 25 14:36:04 MDT 2017"
ACTUAL RESULTS: "Tue Jan 13 09:25:45 MST 1970"
Observations
1. The generated code does a cursor.getInt(0) instead of a cursor.getLong(0)
2. The code then converts the int to a String, then a String to a Long
3. Why do I need to specify a converter on the Dao function if I defined the converter already in the Entity? (I get a an error during compile if I don't provide a "@TypeConverters(DateLongConverter::class)" on the Dao function)