Skip to content

Commit 90e4b5e

Browse files
committed
use export format to prevent https://stackoverflow.com/q/78429143/737857
1 parent b0dd8ec commit 90e4b5e

File tree

5 files changed

+23
-20
lines changed

5 files changed

+23
-20
lines changed

firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt

+6-4
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,15 @@ actual class DataSnapshot internal constructor(
227227

228228
actual val ref: DatabaseReference get() = DatabaseReference(android.ref, persistenceEnabled)
229229

230-
actual val value get() = android.value
231-
230+
actual val value get(): Any? {
231+
check(!hasChildren) { "DataSnapshot.value can only be used for primitive values (snapshots without children)" }
232+
return android.value
233+
}
232234
actual inline fun <reified T> value() =
233-
decode<T>(value = android.value)
235+
decode<T>(value = android.getValue(true))
234236

235237
actual fun <T> value(strategy: DeserializationStrategy<T>) =
236-
decode(strategy, android.value)
238+
decode(strategy, android.getValue(true))
237239

238240
actual fun child(path: String) = DataSnapshot(android.child(path), persistenceEnabled)
239241
actual val hasChildren get() = android.hasChildren()

firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/database.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ actual class DataSnapshot internal constructor(
193193
actual val value get() = ios.value
194194

195195
actual inline fun <reified T> value() =
196-
decode<T>(value = ios.value)
196+
decode<T>(value = ios.valueInExportFormat())
197197

198198
actual fun <T> value(strategy: DeserializationStrategy<T>) =
199-
decode(strategy, ios.value)
199+
decode(strategy, ios.valueInExportFormat())
200200

201201
actual fun child(path: String) = DataSnapshot(ios.childSnapshotForPath(path), persistenceEnabled)
202202
actual val hasChildren get() = ios.hasChildren()

firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/database.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ actual class DataSnapshot internal constructor(
170170
}
171171

172172
actual inline fun <reified T> value() =
173-
rethrow { decode<T>(value = js.`val`()) }
173+
rethrow { decode<T>(value = js.exportVal()) }
174174

175175
actual fun <T> value(strategy: DeserializationStrategy<T>) =
176-
rethrow { decode(strategy, js.`val`()) }
176+
rethrow { decode(strategy, js.exportVal()) }
177177

178178
actual val exists get() = rethrow { js.exists() }
179179
actual val key get() = rethrow { js.key }

firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/externals/database.kt

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ external interface DataSnapshot {
128128
val size: Int
129129
val ref: DatabaseReference
130130
fun `val`(): Any
131+
fun exportVal(): Any
131132
fun exists(): Boolean
132133
fun forEach(action: (a: DataSnapshot) -> Boolean): Boolean
133134
fun child(path: String): DataSnapshot

gradle.properties

+12-12
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ kotlin.mpp.enableCInteropCommonization=true
1919
kotlin.native.cacheKind=none
2020

2121
# Set to true to skip tests and even compilation of the iOS target.
22-
skipIosTarget=false
22+
skipIosTarget=true
2323
# Skip iOS Tests
2424
firebase-app.skipIosTests=false
2525
# We are skipping auth ios tests due to an issue with keychain and simulator.
@@ -47,17 +47,17 @@ firebase-perf.skipJsTests=false
4747
firebase-storage.skipJsTests=false
4848

4949
# Versions:
50-
firebase-app.version=1.11.1
51-
firebase-auth.version=1.11.1
52-
firebase-common.version=1.11.1
53-
firebase-config.version=1.11.1
54-
firebase-database.version=1.11.1
55-
firebase-firestore.version=1.11.1
56-
firebase-functions.version=1.11.1
57-
firebase-installations.version=1.11.1
58-
firebase-perf.version=1.11.1
59-
firebase-crashlytics.version=1.11.1
60-
firebase-storage.version=1.11.1
50+
firebase-app.version=1.11.2
51+
firebase-auth.version=1.11.2
52+
firebase-common.version=1.11.2
53+
firebase-config.version=1.11.2
54+
firebase-database.version=1.11.2
55+
firebase-firestore.version=1.11.2
56+
firebase-functions.version=1.11.2
57+
firebase-installations.version=1.11.2
58+
firebase-perf.version=1.11.2
59+
firebase-crashlytics.version=1.11.2
60+
firebase-storage.version=1.11.2
6161

6262
# Dependencies Versions:
6363
gradlePluginVersion=8.1.3

0 commit comments

Comments
 (0)