Skip to content

Commit 90d17e8

Browse files
authored
Merge pull request #36 from touchlab/kpg/closev2_stringoptimization
Kpg/closev2 stringoptimization
2 parents 3e70279 + 3d05dfc commit 90d17e8

File tree

21 files changed

+335
-58
lines changed

21 files changed

+335
-58
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: build
33
on:
44
pull_request:
55
branches:
6-
- main
6+
- "**"
77
push:
88
branches:
9-
- main
9+
- "**"
1010

1111
jobs:
1212
build:

gradle/gradle-mvn-mpp-push.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ def getGpgKey() {
3939

4040
signing {
4141
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
42-
useInMemoryPgpKeys(getGpgKey(), "")
42+
def gpgKey = getGpgKey()
43+
if(gpgKey != "") {
44+
useInMemoryPgpKeys(getGpgKey(), "")
45+
}
4346
sign(publishing.publications)
4447
}
4548

runtest.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#Runs specific test. Pass in test name.
2+
./gradlew linkDebugTestMacosX64
3+
./sqliter-driver/build/bin/macosX64/debugTest/test.kexe --ktest_regex_filter=.*$1.*

sqliter-driver/runtest.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package co.touchlab.sqliter.interop
2+
3+
import kotlinx.cinterop.*
4+
import platform.Foundation.NSString
5+
import platform.Foundation.create
6+
7+
actual inline fun bytesToString(bv:CPointer<ByteVar>):String = NSString.create(bv).toString()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package co.touchlab.sqliter.interop
2+
3+
import kotlinx.cinterop.*
4+
5+
actual inline fun bytesToString(bv:CPointer<ByteVar>):String = bv.toKStringFromUtf8()

sqliter-driver/src/nativeCommonMain/kotlin/co/touchlab/sqliter/DatabaseConfiguration.kt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,16 @@ data class DatabaseConfiguration(
2424
val version: Int,
2525
val create: (DatabaseConnection) -> Unit,
2626
val upgrade: (DatabaseConnection, Int, Int) -> Unit = { _, _, _ -> },
27-
val foreignKeyConstraints: Boolean = false,
28-
29-
val typeConfig: Type = Type(),
27+
val inMemory: Boolean = false,
28+
val journalMode: JournalMode = JournalMode.WAL,
3029
val extendedConfig:Extended = Extended(),
3130
val loggingConfig:Logging = Logging(),
3231
val lifecycleConfig:Lifecycle = Lifecycle(),
3332
val encryptionConfig:Encryption = Encryption()
3433
) {
35-
data class Type(
36-
val journalMode: JournalMode = JournalMode.WAL,
37-
val inMemory: Boolean = false
38-
)
3934
data class Extended(
40-
val busyTimeout: Int = 2500,
35+
val foreignKeyConstraints: Boolean = false,
36+
val busyTimeout: Int = 5000,
4137
val pageSize: Int? = null,
4238
val basePath: String? = null,
4339
)

sqliter-driver/src/nativeCommonMain/kotlin/co/touchlab/sqliter/DatabaseConnection.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ interface DatabaseConnection {
2222
fun setTransactionSuccessful()
2323
fun endTransaction()
2424
fun close()
25+
val closed:Boolean
2526
}
2627

2728
fun <R> DatabaseConnection.withStatement(sql: String, proc: Statement.() -> R): R {

sqliter-driver/src/nativeCommonMain/kotlin/co/touchlab/sqliter/concurrency/ConcurrentDatabaseConnection.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ class ConcurrentDatabaseConnection(private val delegateConnection:DatabaseConnec
3434

3535
override fun close() = accessLock.withLock { delegateConnection.close() }
3636

37+
override val closed: Boolean
38+
get() = delegateConnection.closed
39+
3740
inner class ConcurrentCursor(private val delegateCursor: Cursor):Cursor{
3841
override fun next(): Boolean = accessLock.withLock { delegateCursor.next() }
3942

sqliter-driver/src/nativeCommonMain/kotlin/co/touchlab/sqliter/createDatabaseManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fun createDatabaseManager(configuration: DatabaseConfiguration): DatabaseManager
2323
return NativeDatabaseManager(databasePath, configuration)
2424
}
2525

26-
internal fun diskOrMemoryPath(configuration: DatabaseConfiguration) = if (configuration.typeConfig.inMemory) {
26+
internal fun diskOrMemoryPath(configuration: DatabaseConfiguration) = if (configuration.inMemory) {
2727
if (configuration.name == null) {
2828
":memory:"
2929
} else {

0 commit comments

Comments
 (0)