@capacitor-community/sqlite 4.0.1 โ†’ 4.1.0-3

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/README.md CHANGED
@@ -28,187 +28,14 @@
28
28
 
29
29
  ## CAPACITOR 4 (Master)
30
30
 
31
- ๐Ÿšจ Release 4.0.1 all platforms ->> ๐Ÿšจ
31
+ For more info on releases:
32
32
 
33
- As no any issues where opened against version 4.0.0-1 using Capacitor 4,
34
- Developers can now install it as normal
33
+ - [info_releases](https://github.com/capacitor-community/sqlite/blob/master/info_releases.md)
35
34
 
36
- ```
37
- npm install @capacitor-community/sqlite@latest
38
- ```
35
+ - [changelog](https://github.com/capacitor-community/sqlite/blob/master/CHANGELOG.md)
39
36
 
40
- ๐Ÿšจ Release 4.0.1 <<- ๐Ÿšจ
37
+ - [issues](https://github.com/capacitor-community/sqlite/issues)
41
38
 
42
- ๐Ÿšจ Release 4.0.0-1 all platforms ->> ๐Ÿšจ
43
- This is a tentative of implementing @Capacitor/core@4.0.1 proposed by rdlabo (Masahiko Sakakibara).
44
- For those who want to try it do
45
- ```
46
- npm install @capacitor-community/sqlite@next
47
- ```
48
- Revert quickly any issue by clearly mentionning V4 in the title of the issue.
49
-
50
- Thanks for your help in testing
51
-
52
- ๐Ÿšจ Release 4.0.0-1 <<- ๐Ÿšจ
53
-
54
- ## CAPACITOR 3 (v3.7.0)
55
-
56
- ๐Ÿšจ Release 3.4.3-3 all platforms ->> ๐Ÿšจ
57
-
58
- The main change is related to the delete table's rows when a synchronization table exists as well as a last_mofidied table's column, allowing for database synchronization of the local database with a remote server database.
59
-
60
- - All existing triggers to YOUR_TABLE_NAME_trigger_last_modified must be modified as follows
61
- ```
62
- CREATE TRIGGER YOUR_TABLE_NAME_trigger_last_modified
63
- AFTER UPDATE ON YOUR_TABLE_NAME
64
- FOR EACH ROW WHEN NEW.last_modified < OLD.last_modified
65
- BEGIN
66
- UPDATE YOUR_TABLE_NAME SET last_modified= (strftime('%s', 'now')) WHERE id=OLD.id;
67
- END;
68
- ```
69
- - an new column `sql_deleted` must be added to each of your tables as
70
- ```
71
- sql_deleted BOOLEAN DEFAULT 0 CHECK (sql_deleted IN (0, 1))
72
- ```
73
- This column will be autommatically set to 1 when you will use a `DELETE FROM ...` sql statement in the `execute`, `run` or `executeSet` methods.
74
-
75
- - In the JSON object that you provide to `importFromJson`, all the deleted rows in your remote server database's tables must have the `sql_deleted` column set to 1. This will indicate to the import process to physically delete the corresponding rows in your local database. All the others rows must have the `sql_deleted` column set to 0.
76
-
77
- - In the JSON object outputs by the `exportToJson`, all the deleted rows in your local database have got the `sql_deleted` column set to 1 to help in your synchronization management process with the remote server database. A system `last_exported_date` is automatically saved in the synchronization table at the start of the export process flow.
78
-
79
- - On successful completion of your synchronization management process with the remote server database, you must
80
- - Set a new synchronization date (as `(new Date()).toISOString()`) with the `setSyncDate` method.
81
- - Execute the `deleteExportedRows` method which physically deletes all table's rows having 1 as value for the `sql_deleted` column prior to the `last_exported_date` in your local database.
82
-
83
- An example of using this new feature is given in [solidjs-vite-sqlite-app](https://github.com/jepiqueau/capacitor-solid-sqlite). It has been used to test the validity of the implementation.
84
-
85
-
86
- ๐Ÿšจ Release 3.4.3-3 <<- ๐Ÿšจ
87
-
88
- ๐Ÿšจ Release 3.4.2-4 ->> ๐Ÿšจ
89
- !!!! DO NOT USE IT !!!!
90
- ๐Ÿšจ Release 3.4.2-4 <<- ๐Ÿšจ
91
-
92
- ๐Ÿšจ Since release 3.4.2-3 ->> ๐Ÿšจ
93
-
94
- - **overwrite** boolean parameter has been added to the Json Object (default false)
95
- - `true` : delete the physically the database whatever the version is.
96
- - `false`:
97
- - re-importing a database with the same `version` number will do nothing, keeping the existing database and will return `changes = 0`
98
- - re-importing a database with a lower `version` number will throw an error `ImportFromJson: Cannot import a version lower than `
99
-
100
- - During an import in `full` mode the `Foreign Key` constraint has been turn off before dropping the tables and turn back on after
101
-
102
- ๐Ÿšจ Since release 3.4.2-3 <<- ๐Ÿšจ
103
- ๐Ÿšจ Since release 3.4.1 ->> ๐Ÿšจ
104
- Databases location for Electron can be set in `the config.config.ts` as followed:
105
-
106
- - for sharing databases between users:
107
-
108
- ```
109
- plugins: {
110
- CapacitorSQLite: {
111
- electronMacLocation: "/YOUR_DATABASES_PATH",
112
- electronWindowsLocation: "C:\\ProgramData\\CapacitorDatabases",
113
- electronLinuxLocation: "/home/CapacitorDatabases"
114
- }
115
- }
116
- ```
117
-
118
- - for only the user in its Home folder
119
-
120
- ```
121
- Plugins: {
122
- CapacitorSQLite: {
123
- electronMacLocation: "Databases",
124
- electronWindowsLocation: "Databases",
125
- electronLinuxLocation: "Databases"
126
- }
127
- }
128
- ```
129
-
130
- For existing databases, YOU MUST COPY old databases to the new location
131
- You MUST remove the Electron folder and add it again with
132
-
133
- ```
134
- npx cap add @capacitor-community/electron
135
- npm run build
136
- cd electron
137
- npm i --save sqlite3
138
- npm i --save @types:sqlite3
139
- npm run rebuild
140
- cd ..
141
- npx cap sync @capacitor-community/electron
142
- npm run build
143
- npx cap copy @capacitor-community/electron
144
- npx cap open @capacitor-community/electron
145
- ```
146
- ๐Ÿšจ Since release 3.4.1 <<- ๐Ÿšจ
147
-
148
- ๐Ÿšจ Since release 3.4.1-1 ->> ๐Ÿšจ
149
-
150
- - add iosIsEncryption, androidIsEncryption in capacitor.config.ts
151
- When your application use only `non-encrypted databases` set those parameter to false then iOS KeyChain & Android MasterKey are not defined.
152
-
153
- ๐Ÿšจ Since release 3.4.1-1 <<- ๐Ÿšจ
154
-
155
- ๐Ÿšจ Since release 3.4.0-2 ->> ๐Ÿšจ
156
-
157
- - iOS & Android only
158
- Adding biometric FaceID/TouchID to secure the pass phrase in the Keychain/SharedPreferences stores. see:
159
- [Biometric_Authentication](https://github.com/capacitor-community/sqlite/blob/master/docs/Biometric-Authentication.md)
160
-
161
- - iOS only
162
- Fix identical pass phrase stored in the Keychain for differents applications using the plugin by adding an application prefix to the Keychain account.
163
- Before the account `"CapacitorSQLitePlugin"` was used and was the same for all applications.
164
- Now by adding `iosKeychainPrefix: 'YOUR_APP_NAME'`in the `capacitor.config.ts` of your application,
165
- the account will be `"YOUR_APP_NAME_CapacitorSQLitePlugin"`
166
- If you were having a pass phrase stored, first modify the `capacitor.config.ts` and then run the command `isSecretStored` which will manage the upgrade of the Keychain account.
167
- ๐Ÿšจ Since release 3.4.0-2 <<- ๐Ÿšจ
168
-
169
- ๐Ÿšจ Since release 3.3.3-2 ->> ๐Ÿšจ
170
-
171
- - iOS only
172
- Support for a database location not visible to iTunes and backed up to iCloud.
173
- For this you must add to the `const config: CapacitorConfig` of the `capacitor.config.ts` file of your application the following:
174
- ```ts
175
- plugins: {
176
- CapacitorSQLite: {
177
- "iosDatabaseLocation": "Library/CapacitorDatabase"
178
- }
179
- }
180
- ```
181
- Pre-existing databases from the `Documents` folder will be moved to the new folder `Library/CapacitorDatabase` and your application will work as before.
182
- If you do not modify the `capacitor.config.ts` file of your application the databases will still reside in the `Documents` folder
183
-
184
- ๐Ÿšจ Since release 3.3.3-2 <<- ๐Ÿšจ
185
-
186
- ๐Ÿšจ Since release 3.2.5-2 ->> ๐Ÿšจ
187
-
188
- - support zip file in copyFromAssets method
189
- - add optional `overwrite` parameter (true/false) default to true
190
-
191
- ๐Ÿšจ Since release 3.2.5-2 <<- ๐Ÿšจ
192
-
193
- ๐Ÿšจ Since release 3.2.3-1 ->> ๐Ÿšจ
194
-
195
- The `initWebStore` and `saveToStore` methods have been added to the Web platform.
196
- - The `initWebStore` has been added to fix the issue#172 and since then is `MANDATORY`
197
- ```js
198
- ...
199
- if(platform === "web") {
200
- await customElements.whenDefined('jeep-sqlite');
201
- const jeepSqliteEl = document.querySelector('jeep-sqlite');
202
- if(jeepSqliteEl != null) {
203
- await sqliteConnection.initWebStore()
204
- ...
205
- }
206
- }
207
- ...
208
- ```
209
- - the `saveToStore` allows to perform intermediate save of the database in case the browser needs to delete the cache.
210
-
211
- ๐Ÿšจ Since release 3.2.3-1 <<- ๐Ÿšจ
212
39
 
213
40
  The test has been achieved on:
214
41
 
@@ -224,6 +51,7 @@ The test has been achieved on:
224
51
 
225
52
  - a [Vue TypeORM app](https://github.com/jepiqueau/vue-typeorm-app)
226
53
 
54
+ - a [SolidJS Vite app](https://github.com/jepiqueau/capacitor-solid-sqlite)
227
55
 
228
56
  ## Browser Support
229
57
 
@@ -315,6 +143,15 @@ npx cap open ios
315
143
  ```
316
144
  npx cap open android
317
145
  ```
146
+ In case you get the following error:
147
+ `x files found with path 'build-data.properties'.`
148
+ You can you add the following code to `app/build.gradle`:
149
+ ```
150
+ packagingOptions {
151
+ exclude 'build-data.properties'
152
+ }
153
+ ```
154
+ See [#301](https://github.com/capacitor-community/sqlite/issues/301) and [SO](https://stackoverflow.com/questions/63291529/how-to-fix-more-than-one-file-was-found-with-os-independent-path-build-data-pro] for more information.
318
155
 
319
156
  ### Electron
320
157
 
@@ -322,15 +159,6 @@ npx cap open android
322
159
  npx cap open @capacitor-community/electron
323
160
  ```
324
161
 
325
- ## Readme previous releases
326
-
327
- [previous releases](https://github.com/capacitor-community/sqlite/readme_previous_release.md)
328
-
329
- ## Issues
330
-
331
- [issues](https://github.com/capacitor-community/sqlite/issues)
332
-
333
-
334
162
  ## Configuration
335
163
 
336
164
  No configuration required for this plugin
@@ -19,6 +19,9 @@ apply plugin: 'com.android.library'
19
19
 
20
20
  android {
21
21
  compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
22
+ packagingOptions {
23
+ exclude 'build-data.properties'
24
+ }
22
25
  defaultConfig {
23
26
  minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
24
27
  targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
@@ -32,9 +35,6 @@ android {
32
35
  proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33
36
  }
34
37
  }
35
- packagingOptions {
36
- exclude 'build-data.properties'
37
- }
38
38
  lintOptions {
39
39
  abortOnError false
40
40
  }
@@ -346,21 +346,37 @@ public class ExportToJson {
346
346
  // for each element of the array split the
347
347
  // first word as key
348
348
  for (int j = 0; j < sch.length; j++) {
349
- String[] row = sch[j].trim().split(" ", 2);
349
+ String sc = sch[j].replaceAll("\n", "").trim();
350
+ String[] row = sc.trim().split(" ", 2);
350
351
  JsonColumn jsonRow = new JsonColumn();
351
- if (row[0].toUpperCase().equals("FOREIGN")) {
352
- Integer oPar = sch[j].indexOf("(");
353
- Integer cPar = sch[j].indexOf(")");
354
- row[0] = sch[j].substring(oPar + 1, cPar);
355
- row[1] = sch[j].substring(cPar + 2);
356
- jsonRow.setForeignkey(row[0]);
357
- } else if (row[0].toUpperCase().equals("CONSTRAINT")) {
358
- String[] tRow = row[1].trim().split(" ", 2);
359
- row[0] = tRow[0];
360
- jsonRow.setConstraint(row[0]);
361
- row[1] = tRow[1];
362
- } else {
363
- jsonRow.setColumn(row[0]);
352
+ Integer oPar;
353
+ Integer cPar;
354
+ switch (row[0].toUpperCase()) {
355
+ case "FOREIGN":
356
+ oPar = sc.indexOf("(");
357
+ cPar = sc.indexOf(")");
358
+ String fk = sc.substring(oPar + 1, cPar);
359
+ row[0] = fk.replaceAll("ยง", ",");
360
+ row[1] = sc.substring(cPar + 2);
361
+ jsonRow.setForeignkey(row[0]);
362
+ break;
363
+ case "PRIMARY":
364
+ oPar = sc.indexOf("(");
365
+ cPar = sc.indexOf(")");
366
+ String pk = sc.substring(oPar + 1, cPar);
367
+ row[0] = "CPK_" + pk.replaceAll("ยง", "_");
368
+ row[0] = row[0].replaceAll("_ ", "_");
369
+ row[1] = sc.substring(cPar + 2);
370
+ jsonRow.setConstraint(row[0]);
371
+ break;
372
+ case "CONSTRAINT":
373
+ String[] tRow = row[1].trim().split(" ", 2);
374
+ row[0] = tRow[0];
375
+ jsonRow.setConstraint(row[0]);
376
+ row[1] = tRow[1];
377
+ break;
378
+ default:
379
+ jsonRow.setColumn(row[0]);
364
380
  }
365
381
  jsonRow.setValue(row[1].replaceAll("ยง", ","));
366
382
  schema.add(jsonRow);
@@ -1503,6 +1503,7 @@ class UtilsJson {
1503
1503
  'column',
1504
1504
  'value',
1505
1505
  'foreignkey',
1506
+ 'primarykey',
1506
1507
  'constraint',
1507
1508
  ];
1508
1509
  if (obj == null ||
@@ -1517,6 +1518,8 @@ class UtilsJson {
1517
1518
  return false;
1518
1519
  if (key === 'foreignkey' && typeof obj[key] != 'string')
1519
1520
  return false;
1521
+ if (key === 'primarykey' && typeof obj[key] != 'string')
1522
+ return false;
1520
1523
  if (key === 'constraint' && typeof obj[key] != 'string')
1521
1524
  return false;
1522
1525
  }
@@ -2038,17 +2041,30 @@ class ExportToJson {
2038
2041
  // first word as key
2039
2042
  for (const sc of sch) {
2040
2043
  const row = [];
2041
- const scht = sc.trim();
2044
+ const scht = sc.replace(/\n/g, '').trim();
2042
2045
  row[0] = scht.substring(0, scht.indexOf(' '));
2043
2046
  row[1] = scht.substring(scht.indexOf(' ') + 1);
2044
2047
  const jsonRow = {};
2045
2048
  if (row[0].toUpperCase() === 'FOREIGN') {
2046
- const oPar = sc.indexOf('(');
2047
- const cPar = sc.indexOf(')');
2048
- row[0] = sc.substring(oPar + 1, cPar);
2049
- row[1] = sc.substring(cPar + 2);
2049
+ const oPar = scht.indexOf('(');
2050
+ const cPar = scht.indexOf(')');
2051
+ const fk = scht.substring(oPar + 1, cPar);
2052
+ const fknames = fk.split('ยง');
2053
+ row[0] = fknames.join(',');
2054
+ row[0] = row[0].replace(/, /g, ',');
2055
+ row[1] = scht.substring(cPar + 2);
2050
2056
  jsonRow['foreignkey'] = row[0];
2051
2057
  }
2058
+ else if (row[0].toUpperCase() === 'PRIMARY') {
2059
+ const oPar = scht.indexOf('(');
2060
+ const cPar = scht.indexOf(')');
2061
+ const pk = scht.substring(oPar + 1, cPar);
2062
+ const pknames = pk.split('ยง');
2063
+ row[0] = 'CPK_' + pknames.join('_');
2064
+ row[0] = row[0].replace(/_ /g, '_');
2065
+ row[1] = scht;
2066
+ jsonRow['constraint'] = row[0];
2067
+ }
2052
2068
  else if (row[0].toUpperCase() === 'CONSTRAINT') {
2053
2069
  const tRow = [];
2054
2070
  const row1t = row[1].trim();