|
|
|
@ -4,6 +4,7 @@ import android.content.Context
|
|
|
|
import androidx.room.Room
|
|
|
|
import androidx.room.Room
|
|
|
|
import androidx.room.RoomDatabase
|
|
|
|
import androidx.room.RoomDatabase
|
|
|
|
import androidx.sqlite.SQLiteConnection
|
|
|
|
import androidx.sqlite.SQLiteConnection
|
|
|
|
|
|
|
|
import androidx.sqlite.SQLiteDriver
|
|
|
|
import androidx.sqlite.driver.bundled.BundledSQLiteDriver
|
|
|
|
import androidx.sqlite.driver.bundled.BundledSQLiteDriver
|
|
|
|
import androidx.sqlite.execSQL
|
|
|
|
import androidx.sqlite.execSQL
|
|
|
|
import com.todoroo.andlib.utility.AndroidUtilities.atLeastR
|
|
|
|
import com.todoroo.andlib.utility.AndroidUtilities.atLeastR
|
|
|
|
@ -79,15 +80,16 @@ fun <T : RoomDatabase> RoomDatabase.Builder<T>.setDriver() =
|
|
|
|
this
|
|
|
|
this
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// need bundled sqlite for window functions
|
|
|
|
val driver = BundledSQLiteDriver() // need bundled sqlite for window functions
|
|
|
|
this
|
|
|
|
this
|
|
|
|
.setDriver(BundledSQLiteDriver())
|
|
|
|
.setDriver(
|
|
|
|
.setQueryCoroutineContext(Dispatchers.IO)
|
|
|
|
object : SQLiteDriver by driver {
|
|
|
|
.addCallback(object : RoomDatabase.Callback() {
|
|
|
|
override fun open(fileName: String): SQLiteConnection {
|
|
|
|
override fun onOpen(connection: SQLiteConnection) {
|
|
|
|
return driver.open(fileName).also {
|
|
|
|
super.onOpen(connection)
|
|
|
|
it.execSQL("PRAGMA busy_timeout = 60000")
|
|
|
|
|
|
|
|
}
|
|
|
|
connection.execSQL("PRAGMA busy_timeout = 60000")
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.setQueryCoroutineContext(Dispatchers.IO)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|