@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.
@@ -819,6 +819,7 @@ class ExportToJson {
819
819
  // MARK: - ExportToJson - CreateSchema
820
820
 
821
821
  // swiftlint:disable function_body_length
822
+ // swiftlint:disable cyclomatic_complexity
822
823
  class func createSchema(stmt: String) throws -> [[String: String]] {
823
824
  var retSchema: [[String: String]] = []
824
825
  // get the sqlStmt between the parenthesis sqlStmt
@@ -836,14 +837,8 @@ class ExportToJson {
836
837
  var row = rstr.split(separator: " ", maxSplits: 1)
837
838
  if row.count == 2 {
838
839
  var columns: [String: String] = [:]
839
- if String(row[0]).uppercased() != "FOREIGN" && String(row[0]).uppercased() != "CONSTRAINT" {
840
- columns["column"] = String(row[0])
841
- } else if String(row[0]).uppercased() == "CONSTRAINT" {
842
- let tRow = row[1].split(separator: " ", maxSplits: 1)
843
- row[0] = tRow[0]
844
- columns["constraint"] = String(row[0])
845
- row[1] = tRow[1]
846
- } else {
840
+ switch String(row[0]).uppercased() {
841
+ case "FOREIGN":
847
842
  guard let oPar = rstr.firstIndex(of: "(")
848
843
  else {
849
844
  var msg: String = "Create Schema "
@@ -860,9 +855,45 @@ class ExportToJson {
860
855
  }
861
856
  row[0] = rstr[rstr.index(
862
857
  after: oPar)..<cPar]
863
- row[1] = rstr[rstr.index(
864
- cPar, offsetBy: 2)..<rstr.endIndex]
858
+ row[1] = rstr[rstr.index(cPar,
859
+ offsetBy: 2)..<rstr.endIndex]
865
860
  columns["foreignkey"] = String(row[0])
861
+ .replacingOccurrences(of: "§",
862
+ with: ",")
863
+ .replacingOccurrences(of: ", ",
864
+ with: ",")
865
+ case "PRIMARY":
866
+ guard let oPar = rstr.firstIndex(of: "(")
867
+ else {
868
+ var msg: String = "Create Schema "
869
+ msg.append("PRIMARY KEY no '('")
870
+ throw ExportToJsonError
871
+ .createSchema(message: msg)
872
+ }
873
+ guard let cPar = rstr.firstIndex(of: ")")
874
+ else {
875
+ var msg: String = "Create Schema "
876
+ msg.append("PRIMARY KEY no ')'")
877
+ throw ExportToJsonError
878
+ .createSchema(message: msg)
879
+ }
880
+ row[0] = rstr[rstr.index(
881
+ after: oPar)..<cPar]
882
+ row[1] = rstr[rstr.index(rstr.startIndex,
883
+ offsetBy: 0)..<rstr.endIndex]
884
+ columns["constraint"] = "CPK_" + String(row[0])
885
+ .replacingOccurrences(of: "§",
886
+ with: "_")
887
+ .replacingOccurrences(of: "_ ",
888
+ with: "_")
889
+ case "CONSTRAINT":
890
+ let tRow = row[1].split(separator: " ",
891
+ maxSplits: 1)
892
+ row[0] = tRow[0]
893
+ columns["constraint"] = String(row[0])
894
+ row[1] = tRow[1]
895
+ default:
896
+ columns["column"] = String(row[0])
866
897
  }
867
898
  columns["value"] = String(row[1]).replacingOccurrences(of: "§", with: ",")
868
899
  retSchema.append(columns)
@@ -886,6 +917,7 @@ class ExportToJson {
886
917
  }
887
918
  return retSchema
888
919
  }
920
+ // swiftlint:enable cyclomatic_complexity
889
921
  // swiftlint:enable function_body_length
890
922
 
891
923
  // MARK: - ExportToJson - CreateIndexes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/sqlite",
3
- "version": "4.0.1",
3
+ "version": "4.1.0-1",
4
4
  "description": "Community plugin for native & electron SQLite databases",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -55,10 +55,10 @@
55
55
  "prepublishOnly": "npm run build && npm run build-electron && npm run docgen"
56
56
  },
57
57
  "devDependencies": {
58
- "@capacitor/android": "^4.0.1",
59
- "@capacitor/core": "^4.0.1",
58
+ "@capacitor/android": "^4.1.0",
59
+ "@capacitor/core": "^4.1.0",
60
60
  "@capacitor/docgen": "^0.0.17",
61
- "@capacitor/ios": "^4.0.1",
61
+ "@capacitor/ios": "^4.1.0",
62
62
  "@ionic/eslint-config": "^0.3.0",
63
63
  "@ionic/prettier-config": "^1.0.1",
64
64
  "@ionic/swiftlint-config": "^1.1.2",
@@ -93,6 +93,6 @@
93
93
  }
94
94
  },
95
95
  "dependencies": {
96
- "jeep-sqlite": "^1.5.5"
96
+ "jeep-sqlite": "^1.5.6"
97
97
  }
98
98
  }