@capacitor-community/sqlite 4.0.1 → 4.1.0-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.
@@ -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();