Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit b5597d79 authored by Luca Stefani's avatar Luca Stefani Committed by Sebastiano Barezzi
Browse files

Twelve: Lowercase cursor column names

Since this used to work _before_ it means
I somehow had uppercase column names here.

Be safe and lowercase them.

Change-Id: I4d7c8d6e017c5fa9af0d983cb0a21cc235a4b04e
parent 1a2d65a0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
/*
 * SPDX-FileCopyrightText: 2023 The LineageOS Project
 * SPDX-FileCopyrightText: 2023-2025 The LineageOS Project
 * SPDX-License-Identifier: Apache-2.0
 */

@@ -15,7 +15,7 @@ fun <T> Cursor?.mapEachRow(
        return@use emptyList<T>()
    }

    val columnIndexCache = ColumnIndexCache(cursor, cursor.columnNames)
    val columnIndexCache = ColumnIndexCache(cursor)

    val data = mutableListOf<T>()
    do {
+7 −3
Original line number Diff line number Diff line
/*
 * SPDX-FileCopyrightText: 2024 The LineageOS Project
 * SPDX-FileCopyrightText: 2024-2025 The LineageOS Project
 * SPDX-License-Identifier: Apache-2.0
 */

@@ -8,8 +8,12 @@ package org.lineageos.twelve.models
import android.database.Cursor
import androidx.core.database.getStringOrNull

class ColumnIndexCache(private val cursor: Cursor, projection: Array<String>) {
    private val indexMap = projection.associateWith { cursor.getColumnIndexOrThrow(it) }
class ColumnIndexCache(private val cursor: Cursor) {
    private val indexMap = cursor.columnNames.associate { columnName ->
        columnName.lowercase().let {
            it to cursor.getColumnIndexOrThrow(it)
        }
    }

    fun getInt(columnName: String) = cursor.getInt(indexMap[columnName]!!)
    fun getLong(columnName: String) = cursor.getLong(indexMap[columnName]!!)