expo-sqlite 11.7.0 → 11.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/android/build.gradle +3 -3
- package/android/src/main/java/expo/modules/sqlite/SQLRecords.kt +8 -0
- package/android/src/main/java/expo/modules/sqlite/SQLiteModule.kt +47 -18
- package/android/src/main/jniLibs/arm64/libcrsqlite.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libcrsqlite.so +0 -0
- package/ios/ExpoSQLite.podspec +1 -1
- package/ios/crsqlite.xcframework/Info.plist +5 -5
- package/ios/crsqlite.xcframework/ios-arm64/crsqlite.framework/crsqlite +0 -0
- package/ios/crsqlite.xcframework/ios-arm64_x86_64-simulator/crsqlite.framework/crsqlite +0 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 11.7.1 — 2023-09-18
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Fix broken JS test. ([#24498](https://github.com/expo/expo/pull/24498) by [@alanjhughes](https://github.com/alanjhughes))
|
|
18
|
+
|
|
19
|
+
### 💡 Others
|
|
20
|
+
|
|
21
|
+
- [iOS] Bump `SQLite`version to latest. ([#24375](https://github.com/expo/expo/pull/24375) by [@alanjhughes](https://github.com/alanjhughes))
|
|
22
|
+
|
|
13
23
|
## 11.7.0 — 2023-09-15
|
|
14
24
|
|
|
15
25
|
### 🐛 Bug fixes
|
|
@@ -21,6 +31,7 @@
|
|
|
21
31
|
### 🎉 New features
|
|
22
32
|
|
|
23
33
|
- Add support for running raw queries on Android. ([#24320](https://github.com/expo/expo/pull/24320) by [@alanjhughes](https://github.com/alanjhughes))
|
|
34
|
+
- On Android, add support for `CRSQLite`. ([#24322](https://github.com/expo/expo/pull/24322) by [@alanjhughes](https://github.com/alanjhughes))
|
|
24
35
|
|
|
25
36
|
### 🐛 Bug fixes
|
|
26
37
|
|
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '11.7.
|
|
6
|
+
version = '11.7.1'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -70,7 +70,7 @@ android {
|
|
|
70
70
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
71
71
|
targetSdkVersion safeExtGet("targetSdkVersion", 33)
|
|
72
72
|
versionCode 18
|
|
73
|
-
versionName "11.7.
|
|
73
|
+
versionName "11.7.1"
|
|
74
74
|
}
|
|
75
75
|
lintOptions {
|
|
76
76
|
abortOnError false
|
|
@@ -85,7 +85,7 @@ android {
|
|
|
85
85
|
dependencies {
|
|
86
86
|
implementation project(':expo-modules-core')
|
|
87
87
|
|
|
88
|
-
implementation 'com.github.
|
|
88
|
+
implementation 'com.github.alanjhughes:sqlite-android:0.0.3'
|
|
89
89
|
implementation "androidx.sqlite:sqlite-ktx:2.3.1"
|
|
90
90
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
|
|
91
91
|
}
|
|
@@ -2,6 +2,7 @@ package expo.modules.sqlite
|
|
|
2
2
|
|
|
3
3
|
import expo.modules.kotlin.records.Field
|
|
4
4
|
import expo.modules.kotlin.records.Record
|
|
5
|
+
import expo.modules.kotlin.types.Enumerable
|
|
5
6
|
|
|
6
7
|
data class Query(
|
|
7
8
|
@Field
|
|
@@ -9,3 +10,10 @@ data class Query(
|
|
|
9
10
|
@Field
|
|
10
11
|
val args: List<Any?>
|
|
11
12
|
) : Record
|
|
13
|
+
|
|
14
|
+
enum class SqlAction(val value: String) : Enumerable {
|
|
15
|
+
INSERT("insert"),
|
|
16
|
+
UPDATE("update"),
|
|
17
|
+
DELETE("delete"),
|
|
18
|
+
UNKNOWN("unknown")
|
|
19
|
+
}
|
|
@@ -3,10 +3,13 @@ package expo.modules.sqlite
|
|
|
3
3
|
|
|
4
4
|
import android.content.Context
|
|
5
5
|
import android.database.Cursor
|
|
6
|
-
import
|
|
6
|
+
import androidx.core.os.bundleOf
|
|
7
7
|
import expo.modules.kotlin.exception.Exceptions
|
|
8
8
|
import expo.modules.kotlin.modules.Module
|
|
9
9
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
10
|
+
import io.expo.android.database.sqlite.SQLiteCustomExtension
|
|
11
|
+
import io.expo.android.database.sqlite.SQLiteDatabase
|
|
12
|
+
import io.expo.android.database.sqlite.SQLiteDatabaseConfiguration
|
|
10
13
|
import java.io.File
|
|
11
14
|
import java.io.IOException
|
|
12
15
|
import java.util.*
|
|
@@ -23,6 +26,8 @@ class SQLiteModule : Module() {
|
|
|
23
26
|
override fun definition() = ModuleDefinition {
|
|
24
27
|
Name("ExpoSQLite")
|
|
25
28
|
|
|
29
|
+
Events("onDatabaseChange")
|
|
30
|
+
|
|
26
31
|
AsyncFunction("exec") { dbName: String, queries: List<Query>, readOnly: Boolean ->
|
|
27
32
|
return@AsyncFunction execute(dbName, queries, readOnly)
|
|
28
33
|
}
|
|
@@ -55,6 +60,12 @@ class SQLiteModule : Module() {
|
|
|
55
60
|
throw DeleteDatabaseException(dbName)
|
|
56
61
|
}
|
|
57
62
|
}
|
|
63
|
+
|
|
64
|
+
OnDestroy {
|
|
65
|
+
DATABASES.values.forEach {
|
|
66
|
+
it?.rawQuery("SELECT crsql_finalize()", emptyArray())
|
|
67
|
+
}
|
|
68
|
+
}
|
|
58
69
|
}
|
|
59
70
|
|
|
60
71
|
private fun execute(dbName: String, queries: List<Query>, readOnly: Boolean, raw: Boolean = false): List<Any> {
|
|
@@ -141,20 +152,11 @@ class SQLiteModule : Module() {
|
|
|
141
152
|
}
|
|
142
153
|
|
|
143
154
|
if (isInsert(sql)) {
|
|
144
|
-
val rowsAffected = getRowsAffected(db)
|
|
145
|
-
|
|
146
|
-
it.second
|
|
147
|
-
}
|
|
148
|
-
val insertId = getInsertId(db).let {
|
|
149
|
-
it.first.close()
|
|
150
|
-
it.second
|
|
151
|
-
}
|
|
155
|
+
val rowsAffected = getRowsAffected(db)
|
|
156
|
+
val insertId = getInsertId(db)
|
|
152
157
|
SQLitePluginResult(rows, columnNames, rowsAffected, insertId, null)
|
|
153
158
|
} else if (isDelete(sql) || isUpdate(sql)) {
|
|
154
|
-
val rowsAffected = getRowsAffected(db)
|
|
155
|
-
it.first.close()
|
|
156
|
-
it.second
|
|
157
|
-
}
|
|
159
|
+
val rowsAffected = getRowsAffected(db)
|
|
158
160
|
SQLitePluginResult(rows, columnNames, rowsAffected, 0, null)
|
|
159
161
|
} else {
|
|
160
162
|
EMPTY_RESULT
|
|
@@ -164,7 +166,7 @@ class SQLiteModule : Module() {
|
|
|
164
166
|
|
|
165
167
|
private fun getRowsAffected(
|
|
166
168
|
db: SQLiteDatabase,
|
|
167
|
-
):
|
|
169
|
+
): Int {
|
|
168
170
|
val cursor = db.rawQuery("SELECT changes() AS numRowsAffected", null)
|
|
169
171
|
val rowsAffected = if (cursor.moveToFirst()) {
|
|
170
172
|
val index = cursor.getColumnIndex("numRowsAffected")
|
|
@@ -172,12 +174,13 @@ class SQLiteModule : Module() {
|
|
|
172
174
|
} else {
|
|
173
175
|
-1
|
|
174
176
|
}
|
|
175
|
-
|
|
177
|
+
cursor.close()
|
|
178
|
+
return rowsAffected
|
|
176
179
|
}
|
|
177
180
|
|
|
178
181
|
private fun getInsertId(
|
|
179
182
|
db: SQLiteDatabase,
|
|
180
|
-
):
|
|
183
|
+
): Long {
|
|
181
184
|
val cursor = db.rawQuery("SELECT last_insert_rowid() AS insertId", null)
|
|
182
185
|
val insertId = if (cursor.moveToFirst()) {
|
|
183
186
|
val index = cursor.getColumnIndex("insertId")
|
|
@@ -185,7 +188,8 @@ class SQLiteModule : Module() {
|
|
|
185
188
|
} else {
|
|
186
189
|
-1
|
|
187
190
|
}
|
|
188
|
-
|
|
191
|
+
cursor.close()
|
|
192
|
+
return insertId
|
|
189
193
|
}
|
|
190
194
|
|
|
191
195
|
// do a select operation
|
|
@@ -245,12 +249,37 @@ class SQLiteModule : Module() {
|
|
|
245
249
|
}
|
|
246
250
|
if (database == null) {
|
|
247
251
|
DATABASES.remove(name)
|
|
248
|
-
|
|
252
|
+
val config = createConfig(path)
|
|
253
|
+
database = SQLiteDatabase.openDatabase(config, null, null)
|
|
254
|
+
addUpdateListener(database)
|
|
249
255
|
DATABASES[name] = database
|
|
250
256
|
}
|
|
251
257
|
return database!!
|
|
252
258
|
}
|
|
253
259
|
|
|
260
|
+
private fun createConfig(path: String): SQLiteDatabaseConfiguration {
|
|
261
|
+
val crsqliteExtension = SQLiteCustomExtension("libcrsqlite", "sqlite3_crsqlite_init")
|
|
262
|
+
return SQLiteDatabaseConfiguration(path, SQLiteDatabase.CREATE_IF_NECESSARY, emptyList(), emptyList(), listOf(crsqliteExtension))
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
private fun addUpdateListener(database: SQLiteDatabase?) {
|
|
266
|
+
database?.addUpdateListener { tableName: String, operationType: Int, rowID: Int ->
|
|
267
|
+
sendEvent(
|
|
268
|
+
"onDatabaseChange",
|
|
269
|
+
bundleOf(
|
|
270
|
+
"tableName" to tableName,
|
|
271
|
+
"rowId" to rowID,
|
|
272
|
+
"typeId" to when (operationType) {
|
|
273
|
+
9 -> SqlAction.DELETE.value
|
|
274
|
+
18 -> SqlAction.INSERT.value
|
|
275
|
+
23 -> SqlAction.UPDATE.value
|
|
276
|
+
else -> SqlAction.UNKNOWN.value
|
|
277
|
+
}
|
|
278
|
+
)
|
|
279
|
+
)
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
254
283
|
internal class SQLitePluginResult(
|
|
255
284
|
val rows: Array<Array<Any?>>,
|
|
256
285
|
val columns: Array<String?>,
|
|
Binary file
|
|
Binary file
|
package/ios/ExpoSQLite.podspec
CHANGED
|
@@ -15,7 +15,7 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
s.static_framework = true
|
|
16
16
|
s.dependency 'ExpoModulesCore'
|
|
17
17
|
# The builtin sqlite does not support extensions so we update it
|
|
18
|
-
s.dependency 'sqlite3', '3.
|
|
18
|
+
s.dependency 'sqlite3', '~> 3.42.0'
|
|
19
19
|
|
|
20
20
|
# Swift/Objective-C compatibility
|
|
21
21
|
s.pod_target_xcconfig = {
|
|
@@ -6,30 +6,30 @@
|
|
|
6
6
|
<array>
|
|
7
7
|
<dict>
|
|
8
8
|
<key>LibraryIdentifier</key>
|
|
9
|
-
<string>ios-
|
|
9
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
10
10
|
<key>LibraryPath</key>
|
|
11
11
|
<string>crsqlite.framework</string>
|
|
12
12
|
<key>SupportedArchitectures</key>
|
|
13
13
|
<array>
|
|
14
14
|
<string>arm64</string>
|
|
15
|
+
<string>x86_64</string>
|
|
15
16
|
</array>
|
|
16
17
|
<key>SupportedPlatform</key>
|
|
17
18
|
<string>ios</string>
|
|
19
|
+
<key>SupportedPlatformVariant</key>
|
|
20
|
+
<string>simulator</string>
|
|
18
21
|
</dict>
|
|
19
22
|
<dict>
|
|
20
23
|
<key>LibraryIdentifier</key>
|
|
21
|
-
<string>ios-
|
|
24
|
+
<string>ios-arm64</string>
|
|
22
25
|
<key>LibraryPath</key>
|
|
23
26
|
<string>crsqlite.framework</string>
|
|
24
27
|
<key>SupportedArchitectures</key>
|
|
25
28
|
<array>
|
|
26
29
|
<string>arm64</string>
|
|
27
|
-
<string>x86_64</string>
|
|
28
30
|
</array>
|
|
29
31
|
<key>SupportedPlatform</key>
|
|
30
32
|
<string>ios</string>
|
|
31
|
-
<key>SupportedPlatformVariant</key>
|
|
32
|
-
<string>simulator</string>
|
|
33
33
|
</dict>
|
|
34
34
|
</array>
|
|
35
35
|
<key>CFBundlePackageType</key>
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-sqlite",
|
|
3
|
-
"version": "11.7.
|
|
3
|
+
"version": "11.7.1",
|
|
4
4
|
"description": "Provides access to a database that can be queried through a WebSQL-like API (https://www.w3.org/TR/webdatabase/). The database is persisted across restarts of your app.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"expo": "*"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "62f76105dfb436f7144440d6e6077d4ff3263842"
|
|
48
48
|
}
|