Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
seadowg committed Sep 10, 2024
1 parent 4128ec4 commit a154665
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class DatabaseEntitiesRepository(context: Context, dbPath: String) : EntitiesRep
}

databaseConnection.withConnection {
writeableDatabase.update(
writableDatabase.update(
ListsTable.TABLE_NAME,
contentValues,
"${ListsTable.COLUMN_NAME} = ?",
Expand Down Expand Up @@ -184,10 +184,10 @@ class DatabaseEntitiesRepository(context: Context, dbPath: String) : EntitiesRep
override fun clear() {
databaseConnection.withConnection {
getLists().forEach {
writeableDatabase.delete(it)
writableDatabase.delete(it)
}

writeableDatabase.delete(ListsTable.TABLE_NAME)
writableDatabase.delete(ListsTable.TABLE_NAME)
}
}

Expand All @@ -201,7 +201,7 @@ class DatabaseEntitiesRepository(context: Context, dbPath: String) : EntitiesRep
override fun delete(id: String) {
databaseConnection.withConnection {
getLists().forEach {
writeableDatabase.delete(
writableDatabase.delete(
it,
"${EntitiesTable.COLUMN_ID} = ?",
arrayOf(id)
Expand Down Expand Up @@ -317,13 +317,13 @@ class DatabaseEntitiesRepository(context: Context, dbPath: String) : EntitiesRep
private fun updateRowIdTables() {
databaseConnection.withConnection {
getLists().forEach {
writeableDatabase.execSQL(
writableDatabase.execSQL(
"""
DROP TABLE IF EXISTS ${getRowIdTableName(it)};
""".trimIndent()
)

writeableDatabase.execSQL(
writableDatabase.execSQL(
"""
CREATE TABLE ${getRowIdTableName(it)} AS SELECT _id FROM $it;
""".trimIndent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ private Cursor queryAndReturnCursor(Map<String, String> projectionMap, String[]
}

private Long insertForm(ContentValues values) {
SQLiteDatabase writeableDatabase = databaseConnection.getWriteableDatabase();
return writeableDatabase.insertOrThrow(FORMS_TABLE_NAME, null, values);
SQLiteDatabase writableDatabase = databaseConnection.getWritableDatabase();
return writableDatabase.insertOrThrow(FORMS_TABLE_NAME, null, values);
}

private void updateForm(Long id, ContentValues values) {
SQLiteDatabase writeableDatabase = databaseConnection.getWriteableDatabase();
writeableDatabase.update(FORMS_TABLE_NAME, values, _ID + "=?", new String[]{String.valueOf(id)});
SQLiteDatabase writableDatabase = databaseConnection.getWritableDatabase();
writableDatabase.update(FORMS_TABLE_NAME, values, _ID + "=?", new String[]{String.valueOf(id)});
}

private void deleteForms(String selection, String[] selectionArgs) {
Expand All @@ -255,8 +255,8 @@ private void deleteForms(String selection, String[] selectionArgs) {
deleteFilesForForm(form);
}

SQLiteDatabase writeableDatabase = databaseConnection.getWriteableDatabase();
writeableDatabase.delete(FORMS_TABLE_NAME, selection, selectionArgs);
SQLiteDatabase writableDatabase = databaseConnection.getWritableDatabase();
writableDatabase.delete(FORMS_TABLE_NAME, selection, selectionArgs);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public List<Instance> getAllNotDeletedByFormIdAndVersion(String jrFormId, String
public void delete(Long id) {
Instance instance = get(id);

databaseConnection.getWriteableDatabase().delete(
databaseConnection.getWritableDatabase().delete(
INSTANCES_TABLE_NAME,
_ID + "=?",
new String[]{String.valueOf(id)}
Expand All @@ -157,7 +157,7 @@ public void delete(Long id) {
public void deleteAll() {
List<Instance> instances = getAll();

databaseConnection.getWriteableDatabase().delete(
databaseConnection.getWritableDatabase().delete(
INSTANCES_TABLE_NAME,
null,
null
Expand Down Expand Up @@ -253,15 +253,15 @@ private Cursor query(String[] projection, String selection, String[] selectionAr
}

private long insert(ContentValues values) {
return databaseConnection.getWriteableDatabase().insertOrThrow(
return databaseConnection.getWritableDatabase().insertOrThrow(
INSTANCES_TABLE_NAME,
null,
values
);
}

private void update(Long instanceId, ContentValues values) {
databaseConnection.getWriteableDatabase().update(
databaseConnection.getWritableDatabase().update(
INSTANCES_TABLE_NAME,
values,
_ID + "=?",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class DatabaseSavepointsRepository(
val values = getValuesFromSavepoint(savepoint, cachePath, instancesPath)

databaseConnection
.writeableDatabase
.writableDatabase
.insertOrThrow(SAVEPOINTS_TABLE_NAME, null, values)
}

Expand All @@ -86,7 +86,7 @@ class DatabaseSavepointsRepository(
}

databaseConnection
.writeableDatabase
.writableDatabase
.delete(SAVEPOINTS_TABLE_NAME, selection, selectionArgs)

File(savepoint.savepointFilePath).delete()
Expand All @@ -98,7 +98,7 @@ class DatabaseSavepointsRepository(
}

databaseConnection
.writeableDatabase
.writableDatabase
.delete(SAVEPOINTS_TABLE_NAME)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ open class DatabaseConnection @JvmOverloads constructor(

private val databasePath = path + File.separator + name

val writeableDatabase: SQLiteDatabase
val writableDatabase: SQLiteDatabase
get() {
StrictMode.noteSlowCall("Accessing writable DB")
return dbHelper.writableDatabase
Expand Down Expand Up @@ -73,7 +73,7 @@ open class DatabaseConnection @JvmOverloads constructor(
*
* This can be dangerous if the database is being access by multiple threads as the connection
* might be closed while a transaction is running or while another thread is using a
* [SQLiteDatabase] instance obtained via [writeableDatabase] or [readableDatabase]. Using
* [SQLiteDatabase] instance obtained via [writableDatabase] or [readableDatabase]. Using
* [SynchronizedDatabaseConnection] is recommended in those scenarios.
*/
fun reset() {
Expand All @@ -85,10 +85,9 @@ open class DatabaseConnection @JvmOverloads constructor(
* used if a calls to [reset] will be made.
*
* Does not guarantee synchronized access if this or another [DatabaseConnection] for the
* same `.db` file uses [writeableDatabase] or [readableDatabase].
* same `.db` file uses [writableDatabase] or [readableDatabase].
* [SynchronizedDatabaseConnection] can be used to ensure synchronized writes/reads to the
* underlying DB.
*
*/
fun <T> withSynchronizedConnection(block: DatabaseConnection.() -> T): T {
return synchronized(dbHelper) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SynchronizedDatabaseConnection(
body: SQLiteDatabase.() -> T
) {
return withConnection {
writeableDatabase.transaction {
writableDatabase.transaction {
body()
}
}
Expand Down

0 comments on commit a154665

Please sign in to comment.