jeep-sqlite
Advanced tools
Comparing version 2.4.1 to 2.4.2
@@ -22,2 +22,3 @@ class UtilsSQLStatement { | ||
let columnValuePairs; | ||
// TODO "OR" and "NOT" | ||
if (whereClause.includes("AND")) { | ||
@@ -35,3 +36,3 @@ // Split the WHERE clause based on the "AND" keyword | ||
const modifiedPairs = columnValuePairs.map((pair) => { | ||
const match = pair.match(/(\w+)\s*(=|IN|BETWEEN|LIKE)\s*(.+)/); | ||
const match = pair.match(/(\w+)\s*(=|<|<=|<>|>|>=|IN|BETWEEN|LIKE)\s*(.+)/); | ||
if (!match) { | ||
@@ -83,28 +84,22 @@ return pair; | ||
static extractColumnNames(whereClause) { | ||
const regex = /\b(\w+)\s*(?=[=<>])|(?<=\()\s*(\w+),\s*(\w+)\s*(?=\))|(?<=\bIN\s*\(VALUES\s*\().*?(?=\))|(?<=\bIN\s*\().*?(?=\))|(?<=\bBETWEEN\s*).*?(?=\bAND\b)|(?<=\bLIKE\s*')\w+|\bAND\b/g; | ||
const matches = whereClause.matchAll(regex); | ||
const columnNames = []; | ||
let andGroup = []; | ||
for (const match of matches) { | ||
if (match[0] === 'AND') { | ||
columnNames.push(...andGroup); | ||
andGroup = []; | ||
const keywords = new Set(["AND", "OR", "IN", "VALUES", "LIKE", "BETWEEN", "NOT"]); | ||
const tokens = whereClause.split(/\s|,|\(|\)/); | ||
const columns = []; | ||
let inClause = false; | ||
let inValues = false; | ||
for (const token of tokens) { | ||
if (token === "IN") { | ||
inClause = true; | ||
} | ||
else if (match[1]) { | ||
andGroup.push(match[1]); | ||
else if (inClause && token === "(") { | ||
inValues = true; | ||
} | ||
else if (match[2] && match[3]) { | ||
andGroup.push(match[2]); | ||
andGroup.push(match[3]); | ||
else if (inValues && token === ")") { | ||
inValues = false; | ||
} | ||
else if (match[0]) { | ||
const values = match[0] | ||
.replace(/[()']/g, '') // Remove parentheses and single quotes | ||
.split(',') | ||
.map(value => value.trim()); | ||
andGroup.push(...values); | ||
else if (token.match(/\b[a-zA-Z]\w*\b/) && !inValues && !keywords.has(token.toUpperCase())) { | ||
columns.push(token); | ||
} | ||
} | ||
columnNames.push(...andGroup); | ||
return columnNames; | ||
return Array.from(new Set(columns)); | ||
} | ||
@@ -111,0 +106,0 @@ static flattenMultilineString(input) { |
@@ -1,2 +0,2 @@ | ||
import{p as e,b as t}from"./p-68f52286.js";export{s as setNonce}from"./p-68f52286.js";const o=()=>{const t=import.meta.url;const s={};if(t!==""){s.resourcesUrl=new URL(".",t).href}return e(s)};o().then((e=>t([["p-4e946535",[[1,"jeep-sqlite",{autoSave:[516,"autosave"],wasmPath:[513,"wasmpath"],pickText:[513,"picktext"],saveText:[513,"savetext"],buttonOptions:[513,"buttonoptions"],innerAutoSave:[32],innerWasmPath:[32],innerPickText:[32],innerSaveText:[32],innerButtonOptions:[32],echo:[64],createConnection:[64],isConnection:[64],closeConnection:[64],open:[64],close:[64],getVersion:[64],execute:[64],executeSet:[64],run:[64],query:[64],getTableList:[64],isDBExists:[64],isDBOpen:[64],deleteDatabase:[64],isStoreOpen:[64],copyFromAssets:[64],isTableExists:[64],createSyncTable:[64],getSyncDate:[64],setSyncDate:[64],isJsonValid:[64],importFromJson:[64],exportToJson:[64],deleteExportedRows:[64],addUpgradeStatement:[64],isDatabase:[64],getDatabaseList:[64],checkConnectionsConsistency:[64],saveToStore:[64],saveToLocalDisk:[64],getFromLocalDiskToStore:[64],getFromHTTPRequest:[64]}]]]],e))); | ||
import{p as e,b as t}from"./p-68f52286.js";export{s as setNonce}from"./p-68f52286.js";const o=()=>{const t=import.meta.url;const s={};if(t!==""){s.resourcesUrl=new URL(".",t).href}return e(s)};o().then((e=>t([["p-de5e45f7",[[1,"jeep-sqlite",{autoSave:[516,"autosave"],wasmPath:[513,"wasmpath"],pickText:[513,"picktext"],saveText:[513,"savetext"],buttonOptions:[513,"buttonoptions"],innerAutoSave:[32],innerWasmPath:[32],innerPickText:[32],innerSaveText:[32],innerButtonOptions:[32],echo:[64],createConnection:[64],isConnection:[64],closeConnection:[64],open:[64],close:[64],getVersion:[64],execute:[64],executeSet:[64],run:[64],query:[64],getTableList:[64],isDBExists:[64],isDBOpen:[64],deleteDatabase:[64],isStoreOpen:[64],copyFromAssets:[64],isTableExists:[64],createSyncTable:[64],getSyncDate:[64],setSyncDate:[64],isJsonValid:[64],importFromJson:[64],exportToJson:[64],deleteExportedRows:[64],addUpgradeStatement:[64],isDatabase:[64],getDatabaseList:[64],checkConnectionsConsistency:[64],saveToStore:[64],saveToLocalDisk:[64],getFromLocalDiskToStore:[64],getFromHTTPRequest:[64]}]]]],e))); | ||
//# sourceMappingURL=jeep-sqlite.esm.js.map |
{ | ||
"name": "jeep-sqlite", | ||
"version": "2.4.1", | ||
"version": "2.4.2", | ||
"description": "Browser SQLite Stencil Component", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
7802539
43976