Closed hirengosalia86 closed 1 month ago
Hi @hirengosalia86, thank you for your report. Could you provide full log for this issue?
Hi @joon-won , there are no log outputs, but as you can see in the bulkDelete function, if there are more than 1 eventIds (1,2,3) there only exists 1 '?' corresponding to this, making it as a string '1,2,3'
@joon-won
internal suspend fun bulkDelete(eventIds: List<Long>) = withContext(coroutineDispatcher) {
contentUri
if (!eventIds.isEmpty()) {
val params = List(eventIds.size, {"?"})
val whereClause = "${LogEventTable.COLUMN_ID} in (${params.joinToString(",")})"
database.delete(
LogEventTable.TABLE_LOG_EVENT,
whereClause,
eventIds.toTypedArray()
)
}
}
This should fix it.
Thank you for your reply and suggestion . However will the current code fail when multiple ids are passed? arrayOf()
function will make it a string array [1,2,3]
, and become string when it joins the WHERE clause. Since this is a sqlite in its core, string representation should be working fine. If you were still noticing the deletion failing when you were passing multiple ids, someone in our team will take a look into the issue.
Agreed, string representation works fine in sqlite, but above will be arrayOf(
Delete from <table_name> where <cloumn> in ('1,2,3')
instead of
Delete from <table_name> where <cloumn> in (1, 2, 3)
SQL Lite is untyped so it won't produce an error when trying to compare a column against the wrong datatype, instead what you get is a no-op. In order for this method to work as one would expect the ? in the statement would have to be bound to an array and not a string. Yet the android-database-sqlcipher library that's being used here is not capable of binding the ? to an array, it is only capable in binding single value types (see DatabaseUtils.bindObjectToProgram
). So the outcome is Delete from <table_name> where <cloumn> in ('1,2,3')
.
Thank you for providing your example and explanation, I see the point. I will share this with the team, and look into the issue
This issue is resolved with Amplify Android 2.16.1
please let us know if the issue persists
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.
Before opening, please confirm:
Language and Async Model
Kotlin
Amplify Categories
Not applicable
Gradle script dependencies
Environment information
Please include any relevant guides or documentation you're referencing
No response
Describe the bug
bulkDelete function called in syncLogEventsWithCloudwatch fails on deleteing, when there are more than 1 events. This causes log being duplicated multiple times in cloudwatch
Reproduction steps (if applicable)
No response
Code Snippet
Log output
amplifyconfiguration.json
No response
GraphQL Schema
Additional information and screenshots
No response