Kiprop Victor
12/07/2021, 4:41 PMms
12/08/2021, 4:49 AM@Query("SELECT mutualFriends FROM friends where userId = :userId")
fun getMutualFriends(userId: String): List<Friend> {
// do some further operation with list
// like filter or some other
}
Tower Guidev2
12/12/2021, 7:46 PMKestutis Povilaitis
12/21/2021, 11:24 AMUUID
usage in ROOM database with the new built in adapter. We decided to move from Long
@PrimaryKey
type to UUID
because of integrity reasons. Now we need to migrate those ids. So when writing a migration we use raw SQL where we lose the ability to use built in converters (AFAIU at least) so we can’t insert it as String
or something else (cant use the `UUIDUtil`from ROOM too). What would be the suggested way to migrate Long
ids to UUID
to use the build in adapter? Maybe someone else encountered a similar issue?Tower Guidev2
01/04/2022, 10:11 AMVivek Sharma
01/10/2022, 4:43 PM@Entity
data class Note(
val title: String,
val content: String,
val timestamp: Long,
val color: Int,
@PrimaryKey val id: Int? = null
)
and when I create Note object, and passing null
to id
, what room will assign to it?
In my case it is assigning 1, 2, 3, 4...
like it is autoGenerating, is this correct what I am thinking?
Though I am NOT having autoGenerate = true
in @PrimaryKey
Aidan Low
01/19/2022, 5:21 PM@Transaction
and -Xjvm-default=all
a known issue?
Building on android-room-with-a-view and adding -Xjvm-default=all
to build.gradle and then adding a @Transaction’d deleteAllAndInsert
to WordDao.kt results in
WordDao_Impl.java:84: error: not an enclosing class: WordDao
return WordDao.super.deleteAllAndInsert(word, __cont);
myanmarking
01/25/2022, 4:29 PMMichael Marshall
02/07/2022, 5:13 AM@DatabaseView
take up additional space in app memory (not storage)? Does it generate a temporary in-memory table of the view fields, or does it perform the SELECT
query each time you access the view?uli
03/21/2022, 2:55 PMdatabaseBuilder.openHelperFactory(SupportFactory(passPhrase)).build()
with a wrong password does not fail as it seems to be ‘lazy’. (Well, it’s a factory). The failure only happens on first access.
Additionally I have read somewhere, that accessing a Room/SQLite DB with a wrong password will corrupt it. Is that true?natario1
05/31/2022, 6:14 PMRenameColumn.Entries
is not working properly if you specify more than 1 rename for the same table. Only one is pickedkotlinforandroid
06/20/2022, 1:44 PMfuad
06/25/2022, 12:39 AMzsperske
06/30/2022, 8:12 PM1.7.0
yesterday and Room started giving me issues
error: Each bind variable in the query must have a matching method parameter. Cannot find method parameters for :expiringDate. - com.project.MyDao.getAll(java.util.Date)
error: Unused parameter: arg0 - com.project.MyDao.getAll(java.util.Date)
I tried disabling incremental room with no effect, only updating to the newest Room alpha fixed the issue (which isn’t an option for us, we don’t use alphas)Tower Guidev2
07/12/2022, 6:45 AMError:Not sure how to convert a Cursor to this method's return type
Hitesh Chopra
07/31/2022, 5:40 PMIsaac
08/10/2022, 9:54 AMjuliocbcotta
09/01/2022, 9:12 AMBrandon Howard
09/02/2022, 12:31 PMAn annotation argument must be a compile-time constant
I’m just wondering if there’s another api that could help with this?mattinger
09/19/2022, 9:58 PM> java.lang.IllegalStateException: org.gradle.android.workarounds.RoomSchemaLocationWorkaround cannot be used with an explicit 'room.schemaLocation' annotation processor argument. Please change this to configure the schema location directory via the 'room' project extension:
room {
schemaLocationDir.set(file("roomSchemas"))
}
every bit of developer documentation i can find suggests that this it eh right right way to configure it:
defaultConfig {
javaCompileOptions {
annotationProcessorOptions {
arguments += mapOf(
"room.schemaLocation" to "$projectDir/schemas",
"room.incremental" to "true",
"room.expandProjection" to "true"
)
}
}
}
FunkyMuse
09/20/2022, 7:33 AMWishnuprathikantam
09/27/2022, 4:45 AMRuben Quadros
10/18/2022, 8:54 AMv79
10/18/2022, 7:30 PMv79
10/22/2022, 11:14 AMgetCurrentOdometer
is a suspend function (because, I think, all repository functions which call the DB are supposed to be suspend?) Note that I don't want a LiveData result - it's not going to change value suddenly!Tower Guidev2
10/27/2022, 9:00 AM@Insert(onConflict = OnConflictStrategy.REPLACE)
actually replaces an existing row?
or do i have to do something "clever" myself?v79
10/29/2022, 8:38 AMLocalDateTime
). I'm trying to write a query which would return all events in the last X number of days:
fun getEventsWithin(days: Int): Flow<List<Event>>
I'm really struggling to work out what the SQL would be. The Event
entity has a column called dateTime
of type LocalDateTime
and I have written two @TypeConverter
functions which convert between LocalDateTime
and Long
values.IsaacMart
11/04/2022, 3:51 PMBwaim
11/15/2022, 6:06 PMMap<CategoryEntity, List<CategoryEntity>>
. So, making a query joining on the same table :
@Query(
"SELECT * FROM category as parent" +
"JOIN category as child ON parent.id = child.parent_id"
)
fun loadCategoriesAndSubCategories(): Map<CategoryEntity, List<CategoryEntity>>
It's not working because it's mapping with the column name. I tried to rename all the columns, but it doesn't work too.
Someone knows if it's possible to do it ?v79
11/19/2022, 9:39 AMLiveData
and the other is not? Because I think I need that.v79
11/19/2022, 9:39 AMLiveData
and the other is not? Because I think I need that.init { ]
block in my ViewModel, I need to fetch a fixed value from the database. Currently, the database returns a LiveData object, as I need it like that elsewhere. So I think I'm going to end up in the state where my DAO and repo has the following almost-duplicate functions:
@Query("SELECT * FROM ChargeEvent WHERE id = :id")
fun getChargeEventWithId(id: Long): LiveData<ChargeEvent?>
@Query("SELECT * FROM ChargeEvent WHERE id = :id")
fun getExistingChargeEventWithId(id: Long): ChargeEvent?
Which just looks like a code smell to me. Or rather, a lack-of-understanding smell.Michael Marshall
11/21/2022, 3:08 AMLiveData
instead?Brandon Howard
11/30/2022, 6:20 PMrattleshirt
12/14/2022, 3:00 PMFlow
and call viewModelScope.launch { flow.firstOrNull() }
from init
if you only need it once. Otherwise you could always extract the string from the query as const and reuse it in bothsuspend fun
vs Flow