Skip to content

Commit 818f9cc

Browse files
author
Krzysztof Borowy
committed
fix: drop collation changes
According to Android docs, one needs to be consistent when using NO_COLLATION flag with how database was created, so changing this during runtime makes no sense and can lead to some unexpected errors/behaviors (SQLite default collation rule is BINARY).
1 parent 648e22a commit 818f9cc

File tree

3 files changed

+3
-17
lines changed

3 files changed

+3
-17
lines changed

android/build.gradle

-5
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ def useDedicatedExecutor = rootProject.hasProperty('AsyncStorage_dedicatedExecut
3333
? rootProject.properties['AsyncStorage_dedicatedExecutor']
3434
: false
3535

36-
def disableLocalizedCollators = rootProject.hasProperty('AsyncStorage_noLocalizedCollators')
37-
? rootProject.properties['AsyncStorage_noLocalizedCollators']
38-
: false
39-
4036
apply plugin: 'com.android.library'
4137

4238
android {
@@ -47,7 +43,6 @@ android {
4743
targetSdkVersion safeExtGet('targetSdkVersion', 28)
4844
buildConfigField "Long", "AsyncStorage_db_size", "${dbSizeInMB}L"
4945
buildConfigField("boolean", "AsyncStorage_useDedicatedExecutor", "${useDedicatedExecutor}")
50-
buildConfigField("boolean", "AsyncStorage_noLocalizedCollators", "${disableLocalizedCollators}")
5146
}
5247
lintOptions {
5348
abortOnError false

android/src/main/java/com/reactnativecommunity/asyncstorage/ReactDatabaseSupplier.java

+3-11
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77

88
package com.reactnativecommunity.asyncstorage;
99

10-
import javax.annotation.Nullable;
11-
1210
import android.content.Context;
1311
import android.database.sqlite.SQLiteDatabase;
1412
import android.database.sqlite.SQLiteException;
1513
import android.database.sqlite.SQLiteOpenHelper;
16-
1714
import com.facebook.common.logging.FLog;
1815
import com.facebook.react.common.ReactConstants;
16+
import java.io.File;
17+
import javax.annotation.Nullable;
1918

2019
/**
2120
* Database supplier of the database used by react native. This creates, opens and deletes the
@@ -44,7 +43,6 @@ public class ReactDatabaseSupplier extends SQLiteOpenHelper {
4443
private Context mContext;
4544
private @Nullable SQLiteDatabase mDb;
4645
private long mMaximumDatabaseSize = BuildConfig.AsyncStorage_db_size * 1024L * 1024L;
47-
private boolean disableLocalizedCollators = BuildConfig.AsyncStorage_noLocalizedCollators;
4846

4947
private ReactDatabaseSupplier(Context context) {
5048
super(context, DATABASE_NAME, null, DATABASE_VERSION);
@@ -86,13 +84,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
8684
if (tries > 0) {
8785
deleteDatabase();
8886
}
89-
90-
if(disableLocalizedCollators) {
91-
String dbPath = mContext.getDatabasePath(DATABASE_NAME).getPath();
92-
mDb = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READWRITE);
93-
} else {
94-
mDb = getWritableDatabase();
95-
}
87+
mDb = getWritableDatabase();
9688
break;
9789
} catch (SQLiteException e) {
9890
lastSQLiteException = e;

example/android/gradle.properties

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
# Enable dedicated thread pool executor
2424
AsyncStorage_dedicatedExecutor=true
25-
AsyncStorage_noLocalizedCollators=true
2625

2726
android.useAndroidX=true
2827
android.enableJetifier=true

0 commit comments

Comments
 (0)