Skip to content

Commit 3d4e443

Browse files
committed
Set key pragma in a query instead of statement
This is because SQLCipher returns a row with "ok" after the key is set. This trips a check in the statement logic that throws an error if a row is returned
1 parent ac7d128 commit 3d4e443

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

SQLiter/src/commonMain/kotlin/co/touchlab/sqliter/DatabaseConnection.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fun DatabaseConnection.stringForQuery(sql:String):String = withStatement(sql){
6060
* @param cipherKey the database cipher key
6161
*/
6262
fun DatabaseConnection.setCipherKey(cipherKey: String) {
63-
withStatement("PRAGMA key = \"$cipherKey\";") { execute() }
63+
stringForQuery("PRAGMA key = \"$cipherKey\";")
6464
}
6565

6666
/**
@@ -71,7 +71,7 @@ fun DatabaseConnection.setCipherKey(cipherKey: String) {
7171
*/
7272
fun DatabaseConnection.resetCipherKey(oldKey: String, newKey: String) {
7373
setCipherKey(oldKey)
74-
withStatement("PRAGMA rekey = \"$newKey\";") { execute() }
74+
stringForQuery("PRAGMA rekey = \"$newKey\";")
7575
}
7676

7777
/**

0 commit comments

Comments
 (0)