mreichelt / RoomKspBug

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Room KSP bug (minimal verifiable example)

Using:

  • Room 2.4.0
  • Kotlin 1.5.31
  • KSP 1.5.31-1.0.1

To reproduce the bug:

  1. Note that the Awesomeness enum is missing from User.kt
  2. Note that AppDatabase.kt has two converters - one for Instant, and one for Awesomeness
  3. Run InsertUserIntoDatabaseTest and see that it fails with:
    • java.time.format.DateTimeParseException: Text 'AWESOME' could not be parsed at index 0
    • This means that the string AWESOME has been written to the born_at field! ⚡️🤯
  4. The reason this happens is that the generated code in UserDao_Impl.java contains these lines in the generated bind method:
        final String _tmp = __timeConverter.instantToValue(value.getBornAt());      // this is expected
        final Awesomeness _tmp_1 = __awesomenessConverter.valueToAwesomeness(_tmp); // ⚡️ fail - converting the String to Awesomeness
        final String _tmp_2 = __awesomenessConverter.awesomenessToValue(_tmp_1);

About

License:Apache License 2.0


Languages

Language:Kotlin 100.0%