jw
04/27/2023, 11:36 PMMatheus Finatti
04/28/2023, 2:32 PMuserId <-> groupId
relationship and one to store members, which has a groupId
column.
I’m trying to flatMap
one query into the other, but if I insert a new group under that userId
it doesn’t trigger the chain.
small example:
suspend fun getGroups(userId: String): Flow<List<Groups>> =
userGroupQueries.getGroups(userId)
.asFlow()
.mapToList(coroutineContext)
.flatMapLatest { groupIds: List<String> ->
memberQueries.getAllGroupsMembers(groupIds)
.asFlow()
.mapToList(coroutineContext)
.mapLatest { members -> members.groupBy { it.groupId }}
}
UserGroup.sq
CREATE TABLE UserGroup(
userid TEXT NOT NULL,
groupid TEXT NOT NULL,
FOREIGN KEY (groupid) REFERENCES EGroup(id),
FOREIGN KEY (userid) REFERENCES User(id)
);
getGroups:
SELECT groupid FROM UserGroup WHERE userid = ?;
Member.sq
getAllFromGroupIds:
SELECT * FROM Member WHERE groupid IN ?;
I can try to provide a minimum reproducible example if necessary. Didn’t find anything like this on SO or on github so I wonder if I’m trying to do something sillyPablichjenkov
04/29/2023, 10:23 PMCompiled with problems:
ERROR in ../../node_modules/sql.js/dist/sql-wasm.js 93:11-34
Module not found: Error: Can't resolve 'path' in '<project_path>/build/js/node_modules/sql.js/dist'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "path": false }
ERROR in ../../node_modules/sql.js/dist/sql-wasm.js 93:81-94
Module not found: Error: Can't resolve 'fs' in '<project_path>/build/js/node_modules/sql.js/dist'
Did some research online but all I got was a thread in the sqdelight github project, that didn’t help much.
Thanks in advanceDerek Ellis
04/29/2023, 11:55 PM// project/webpack.config.d/fs.js
config.resolve = {
fallback: {
fs: false,
path: false,
crypto: false,
}
};
Ayla
04/30/2023, 11:52 AMColton Idle
05/01/2023, 1:52 PM"
, it uses '
Is there an easy way to write an interceptor or something that just replace all double quotes with single quotes? I'm using okhttp + retrofit.Sean Proctor
05/02/2023, 2:08 PMexecute
?Derek Ellis
05/02/2023, 2:14 PMSean Proctor
05/02/2023, 2:17 PMhumblehacker
05/02/2023, 4:06 PMhfhbd
05/02/2023, 6:50 PMNeil Miller
05/03/2023, 4:23 PMAyla
05/05/2023, 6:04 AMval tempJob:Job? = null
fun getNotesToday(today:LocalDate){
viewModelScope.launch{
tempJob?.cancel()
tempJob=launch{
database.noteQuery
.getNotesBetween(today.start,today.end)
.asFlow()
.collectLatest{...}
}
}
It seems a bit troublesome to do the same for every situation like this, is there a better way?Davide Giuseppe Farella
05/06/2023, 8:20 AMxxfast
05/09/2023, 9:19 AMokio.IOException
.
Uncaught Kotlin exception: okio.IOException: Operation not permitted
at 0 PSCore 0x10548be63 kfun:okio#errnoToIOException(<http://kotlin.Int|kotlin.Int>){}okio.IOException + 419
Looks like this is thrown from the encoder, which is here and looks like this
override suspend fun encode(value: T?) {
val parentFolder: Path? = path.parent
if (parentFolder != null && !FILE_SYSTEM.exists(parentFolder))
FILE_SYSTEM.createDirectories(parentFolder, mustCreate = false)
if (value != null) FILE_SYSTEM.sink(path).buffer().use { json.encodeToBufferedSink(serializer, value, it) }
else FILE_SYSTEM.delete(path)
}
Unable to reproduce this consistently. But seems to be more prevalent on physical devices compared to the simulator. Raised an issue here. Any idea whats wrong? 🤔Neil Miller
05/09/2023, 5:20 PMPablichjenkov
05/10/2023, 2:43 AMDerek Ellis
05/10/2023, 3:02 AMPablichjenkov
05/10/2023, 3:12 AMdorche
05/10/2023, 1:31 PMjw
05/11/2023, 6:08 PMjw
05/11/2023, 6:08 PMColton Idle
05/11/2023, 6:51 PMyschimke
05/11/2023, 7:33 PMAyla
05/14/2023, 2:16 AMsaket
05/14/2023, 2:38 AMhfhbd
05/14/2023, 7:49 AM—continuous
Raghav
05/16/2023, 7:58 AMMovie(
val genreIds: List<Int?>?
)
To store the above in database
I'm creating a db table like this
CREATE TABLE Movie (
genreIds TEXT AS List<Int>,
);
While instantiating my database I'll need to give a ColumnAdapter to let the SQLDelight know how to store and retrieve genreIds
to and from database. Here is the ColumnAdapter Implementation
val listOfIntsAdapter = object : ColumnAdapter<List<Int>, String> {
override fun decode(databaseValue: String): List<Int> {
return if (databaseValue.isEmpty()) {
emptyList<Int>()
} else {
databaseValue.split(",").map { it.toInt() }
}
}
override fun encode(value: List<Int>) = value.joinToString(separator = ",")
}
But As I'm building the project I'm getting this error
Type mismatch: inferred type is ColumnAdapter<kotlin.collections.List<Int>, String> but ColumnAdapter<java.util.List<Int>, String> was expected
The name of my database is AppDatabase
In the generated AppDatabaseQueries
class in the imports section, Android Studio is not able to resolve this import.
I don't know but this could be the reason for this issue.
Thanks in advancesaket
05/16/2023, 8:08 AMkotlin.collections.List
in your .sq
file?