Skip to content

Commit dd7073c

Browse files
committed
Update to SQLDelight 2.1.0, Kotlin 2.2.20
1 parent 45b709e commit dd7073c

File tree

7 files changed

+108
-108
lines changed

7 files changed

+108
-108
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ supports [sqlite3](https://www.npmjs.com/package/sqlite3) Node.js module
1212

1313
## Gradle set up
1414

15-
Pretty much it's almost the same as with https://sqldelight.github.io/sqldelight/2.0.2/js_sqlite
15+
Pretty much it's almost the same as with https://sqldelight.github.io/sqldelight/2.1.0/js_sqlite
1616

1717
Initialization of SQLDelight is needed
1818

1919
```kotlin
2020
plugins {
21-
kotlin("js") version "2.1.20" // probably would work even with different one
22-
id("app.cash.sqldelight") version "2.0.2" // for version 0.4.0 and higher
21+
kotlin("js") version "2.2.20" // probably would work even with different one
22+
id("app.cash.sqldelight") version "2.1.0" // for version 0.5.0 and higher
2323
}
2424
2525
@@ -42,7 +42,7 @@ kotlin {
4242
binaries.executable()
4343
nodejs {
4444
dependencies {
45-
implementation("cz.sazel.sqldelight:node-sqlite3-driver-js:0.4.1")
45+
implementation("cz.sazel.sqldelight:node-sqlite3-driver-js:0.5.0")
4646
}
4747
}
4848
}
@@ -75,7 +75,7 @@ tasks["kotlinNpmInstall"].finalizedBy(bindingsInstall)
7575

7676
## Simple example
7777

78-
Queries are written as here - https://sqldelight.github.io/sqldelight/2.0.2/js_sqlite/#using-queries
78+
Queries are written as here - https://sqldelight.github.io/sqldelight/2.1.0/js_sqlite/#using-queries
7979

8080
```kotlin
8181
suspend fun main() {
@@ -85,19 +85,19 @@ suspend fun main() {
8585

8686
val playerQueries: PlayerQueries = database.playerQueries
8787

88-
println(playerQueries.selectAll().executeSuspendingAsList())
88+
println(playerQueries.selectAll().awaitAsList())
8989
// Prints [HockeyPlayer(15, "Ryan Getzlaf")]
9090

9191
playerQueries.insert(player_number = 10, full_name = "Corey Perry")
92-
println(playerQueries.selectAll().executeSuspendingAsList())
92+
println(playerQueries.selectAll().awaitAsList())
9393
// Prints [HockeyPlayer(15, "Ryan Getzlaf"), HockeyPlayer(10, "Corey Perry")]
9494

9595
val player = HockeyPlayer(20, "Ronald McDonald")
9696
playerQueries.insertFullPlayerObject(player)
9797
}
9898
```
9999

100-
Note: Please use `executeSuspendingAsList()` or `executeAsFlow()` in queries instead of `executeAsList()`
100+
Note: Please use `awaitAsList()` or `executeAsFlow()` in queries instead of `executeAsList()`
101101
as that API is not suspending and will throw an exception with this driver.
102102

103103
## Thanks

build.gradle.kts

Lines changed: 77 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ plugins {
1616
}
1717

1818
val defaultGroupId = "cz.sazel.sqldelight"
19-
val versionBase = "0.4.0"
19+
val versionBase = "0.5.0"
2020

2121
val localProperties = Properties().apply {
2222
try {
@@ -47,14 +47,12 @@ repositories {
4747
}
4848
}
4949

50-
kotlin {
50+
lateinit var publicationsFromMainHost: List<String>
5151

5252

53-
js(IR) {
54-
compilations.all {
55-
kotlinOptions.moduleKind = "commonjs"
56-
}
53+
kotlin {
5754

55+
js(IR) {
5856
useCommonJs()
5957
nodejs {
6058
kotlinNodeJsEnvSpec.version.set(libs.versions.node.js.get())
@@ -84,7 +82,7 @@ kotlin {
8482
dependencies {
8583
implementation(libs.sqldelight.runtime.js)
8684
implementation(libs.sqldelight.async.extensions.js)
87-
implementation(npm("sqlite3", libs.versions.node.sqlite3.get(), false))
85+
implementation(npm("sqlite3", libs.versions.node.sqlite3.get()))
8886
}
8987
}
9088
val jsTest by getting {
@@ -98,7 +96,7 @@ kotlin {
9896
}
9997
}
10098

101-
val publicationsFromMainHost = listOf(js()).map { it.name } + "kotlinMultiplatform"
99+
publicationsFromMainHost = listOf(js()).map { it.name } + "kotlinMultiplatform"
102100

103101
dokka {
104102
moduleName = "node-sqlite3-driver"
@@ -111,94 +109,95 @@ kotlin {
111109
}
112110
}
113111

114-
val javadocJar = tasks.register<Jar>("javadocJar") {
115-
dependsOn(tasks.dokkaGenerate.get())
116-
archiveClassifier.set("javadoc")
117-
from(layout.buildDirectory.dir("dokka/html"))
118-
}
119112

120-
publishing {
113+
}
114+
}
121115

122-
publications {
123-
matching { it.name in publicationsFromMainHost }.all {
124-
val targetPublication = this@all
125-
tasks.withType<AbstractPublishToMaven>().matching { it.publication == targetPublication }
126-
.configureEach { onlyIf { findProperty("isMainHost") == "true" } }
127-
}
116+
val javadocJar = tasks.register<Jar>("javadocJar") {
117+
dependsOn(tasks.dokkaGenerate.get())
118+
archiveClassifier.set("javadoc")
119+
from(layout.buildDirectory.dir("dokka/html"))
120+
}
128121

122+
publishing {
123+
publications {
124+
matching { it.name in publicationsFromMainHost }.all {
125+
val targetPublication = this@all
126+
tasks.withType<AbstractPublishToMaven>().matching { it.publication == targetPublication }
127+
.configureEach { onlyIf { findProperty("isMainHost") == "true" } }
128+
}
129129

130-
withType<MavenPublication> {
131-
artifact(javadocJar)
132-
133-
pom {
134-
name.set("node-sqlite3-driver")
135-
description.set("Driver for the library SQLDelight that supports sqlite3 Node.js module")
136-
licenses {
137-
license {
138-
name.set("Apache-2.0")
139-
url.set("https://opensource.org/licenses/Apache-2.0")
140-
}
141-
}
142-
url.set("https://github.com/wojta/sqldelight-node-sqlite3-driver")
143-
issueManagement {
144-
system.set("Github")
145-
url.set("https://github.com/wojta/sqldelight-node-sqlite3-driver/issues")
146-
}
147-
scm {
148-
connection.set("https://github.com/wojta/sqldelight-node-sqlite3-driver.git")
149-
url.set("https://github.com/wojta/sqldelight-node-sqlite3-driver")
150-
}
151-
developers {
152-
developer {
153-
name.set("Vojtěch Sázel")
154-
email.set("sqldelight@sazel.cz")
155-
}
156-
}
157-
}
158-
}
159130

160-
}
131+
withType<MavenPublication> {
132+
artifact(javadocJar)
161133

162-
repositories {
163-
val githubUserName = System.getenv("GITHUB_USER") ?: localProperties["github.user"] as String?
164-
if (githubUserName != null) { // Github packages repo
165-
maven {
166-
name = "GitHubPackages"
167-
url = uri("https://maven.pkg.github.com/wojta/sqldelight-node-sqlite3-driver") // Github Package
168-
169-
credentials {
170-
//Fetch these details from the properties file or from Environment variables
171-
username = githubUserName
172-
password = System.getenv("GITHUB_TOKEN") ?: localProperties["github.token"] as String?
173-
}
134+
pom {
135+
name.set("node-sqlite3-driver")
136+
description.set("Driver for the library SQLDelight that supports sqlite3 Node.js module")
137+
licenses {
138+
license {
139+
name.set("Apache-2.0")
140+
url.set("https://opensource.org/licenses/Apache-2.0")
174141
}
175142
}
176-
maven { // OSS Sonatype (default)
177-
val isSnapshot = version.toString().endsWith("SNAPSHOT")
178-
val destination = if (!isSnapshot) {
179-
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
180-
} else "https://s01.oss.sonatype.org/content/repositories/snapshots"
181-
url = uri(destination)
182-
credentials {
183-
username = System.getenv("SONATYPE_USER") ?: localProperties["sonatype.user"] as String?
184-
password = System.getenv("SONATYPE_PASSWORD") ?: localProperties["sonatype.password"] as String?
143+
url.set("https://github.com/wojta/sqldelight-node-sqlite3-driver")
144+
issueManagement {
145+
system.set("Github")
146+
url.set("https://github.com/wojta/sqldelight-node-sqlite3-driver/issues")
147+
}
148+
scm {
149+
connection.set("https://github.com/wojta/sqldelight-node-sqlite3-driver.git")
150+
url.set("https://github.com/wojta/sqldelight-node-sqlite3-driver")
151+
}
152+
developers {
153+
developer {
154+
name.set("Vojtěch Sázel")
155+
email.set("sqldelight@sazel.cz")
185156
}
186157
}
187-
mavenLocal()
188158
}
189159
}
190160

191-
signing {
192-
useInMemoryPgpKeys(
193-
System.getenv("GPG_KEY_SECRET") ?: localProperties["gpg.keySecret"] as String?,
194-
System.getenv("GPG_KEY_PASSWORD") ?: localProperties["gpg.keyPassword"] as String?
195-
)
161+
}
196162

197-
sign(publishing.publications)
163+
repositories {
164+
val githubUserName = System.getenv("GITHUB_USER") ?: localProperties["github.user"] as String?
165+
if (githubUserName != null) { // Github packages repo
166+
maven {
167+
name = "GitHubPackages"
168+
url = uri("https://maven.pkg.github.com/wojta/sqldelight-node-sqlite3-driver") // Github Package
169+
170+
credentials {
171+
//Fetch these details from the properties file or from Environment variables
172+
username = githubUserName
173+
password = System.getenv("GITHUB_TOKEN") ?: localProperties["github.token"] as String?
174+
}
175+
}
176+
}
177+
maven { // OSS Sonatype (default)
178+
val isSnapshot = version.toString().endsWith("SNAPSHOT")
179+
val destination = if (!isSnapshot) {
180+
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
181+
} else "https://s01.oss.sonatype.org/content/repositories/snapshots"
182+
url = uri(destination)
183+
credentials {
184+
username = System.getenv("SONATYPE_USER") ?: localProperties["sonatype.user"] as String?
185+
password = System.getenv("SONATYPE_PASSWORD") ?: localProperties["sonatype.password"] as String?
186+
}
198187
}
188+
mavenLocal()
199189
}
200190
}
201191

192+
signing {
193+
useInMemoryPgpKeys(
194+
System.getenv("GPG_KEY_SECRET") ?: localProperties["gpg.keySecret"] as String?,
195+
System.getenv("GPG_KEY_PASSWORD") ?: localProperties["gpg.keyPassword"] as String?
196+
)
197+
198+
sign(publishing.publications)
199+
}
200+
202201
// workaround for missing sqlite3 bindings
203202
val bindingsInstall = tasks.register("sqlite3BindingsInstall") {
204203
doFirst {

gradle/libs.versions.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[versions]
22
detekt = "1.23.7"
33
dokka = "2.0.0"
4-
kotlin = "2.1.20-Beta1"
5-
kotlinCoroutines = "1.10.1"
4+
kotlin = "2.2.20"
5+
kotlinCoroutines = "1.10.2"
66
kover = "0.9.1"
77
node-sqlite3 = "5.1.7"
88
node-js = "22.13.0"
9-
sqldelight = "2.0.2"
9+
sqldelight = "2.1.0"
1010

1111
[libraries]
1212
kotlin-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinCoroutines" }
@@ -18,6 +18,5 @@ sqldelight-runtime-js = { module = "app.cash.sqldelight:runtime-js", version.ref
1818
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
1919
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
2020
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
21-
kotlin-js = { id = "org.jetbrains.kotlin.js", version.ref = "kotlin" }
2221
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
23-
sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }
22+
sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }

src/jsMain/kotlin/cz/sazel/sqldelight/node/sqlite3/SQLite3Driver.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class SQLite3Driver internal constructor(private val db: Sqlite3.Database) : Sql
5050
if (enclosingTransaction == null) {
5151
statements.onEach { it.value.finalizeSuspending() }
5252
val sql = if (successful) "END TRANSACTION" else "ROLLBACK TRANSACTION"
53-
suspendCoroutine<Any?> { cont ->
53+
suspendCoroutine { cont ->
5454
val callback: (Any?) -> Unit = {
5555
if (it == null || it !is Throwable) {
5656
cont.resume(it)
@@ -136,7 +136,7 @@ class SQLite3Driver internal constructor(private val db: Sqlite3.Database) : Sql
136136
val transaction = Transaction(enclosing)
137137
this.transaction = transaction
138138
if (enclosing == null) {
139-
suspendCoroutine<Any?> { cont ->
139+
suspendCoroutine { cont ->
140140
val callback: (Any?) -> Unit = {
141141
if (it == null || it !is Throwable) {
142142
cont.resume(it)
@@ -186,7 +186,7 @@ class SQLite3Driver internal constructor(private val db: Sqlite3.Database) : Sql
186186
if (parameters > 0) {
187187
val bound = SQLite3PreparedStatement(parameters)
188188
binders(bound)
189-
suspendCoroutine<Any?> { cont ->
189+
suspendCoroutine { cont ->
190190
val callback: (Any?) -> Unit = {
191191
if (it == null || it !is Throwable) {
192192
cont.resume(it)

src/jsMain/kotlin/cz/sazel/sqldelight/node/sqlite3/utils.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import kotlinx.coroutines.flow.toList
1313
* Use this instead of non-async method [Query.executeAsList].
1414
* @return The result set of the underlying SQL statement as a list of RowType.
1515
*/
16+
@Deprecated("Use awaitAsList() instead", ReplaceWith("awaitAsList()"))
1617
suspend fun <T : Any> Query<T>.executeSuspendingAsList(): List<T> =
1718
executeAsFlow().toList(mutableListOf())
1819

0 commit comments

Comments
 (0)