mirror of
https://github.com/pocketbase/pocketbase.git
synced 2026-10-05 22:11:44 +02:00
fixed multiline index column and utrigger index validations if failing to parse all columns
This commit is contained in:
1 parent
f611256d90
commit
1984952e4e
9 files changed
+22
-17
No files matched your search
+4
-4
@@ -1667,14 +1667,14 @@ const utils = {
|
||||
};
|
||||
|
||||
const indexRegex =
|
||||
/\s*create\s+(unique\s+)?\s*index\s*(if\s+not\s+exists\s+)?(\S*)\s+on\s+(\S*)\s*\(([\s\S]*?)\)(?:\s*where\s+([\s\S]*?))?\s*$/gim;
|
||||
/\s*create\s+(unique\s+)?\s*index\s*(if\s+not\s+exists\s+)?(\S*)\s+on\s+(\S*)\s*\(([\s\S]*?)\)(?:\s*where\s+([\s\S]*?))?\s*$/gi;
|
||||
const matches = indexRegex.exec((idx || "").trim());
|
||||
|
||||
if (matches?.length != 7) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const sqlQuoteRegex = /^[\"\'\`\[\{}]|[\"\'\`\]\}]$/gm;
|
||||
const sqlQuoteRegex = /^[\"\'\`\[\{}]|[\"\'\`\]\}]$/g;
|
||||
|
||||
// unique
|
||||
result.unique = matches[1]?.trim().toLowerCase() === "unique";
|
||||
@@ -1697,13 +1697,13 @@ const utils = {
|
||||
|
||||
// columns
|
||||
const rawColumns = (matches[5] || "")
|
||||
.replace(/,(?=[^\(]*\))/gim, "{PB_TEMP}") // temporary replace comma within expressions for easier splitting
|
||||
.replace(/,(?=[^\(]*\))/gi, "{PB_TEMP}") // temporary replace comma within expressions for easier splitting
|
||||
.split(","); // split columns
|
||||
|
||||
for (let col of rawColumns) {
|
||||
col = col.trim().replaceAll("{PB_TEMP}", ","); // revert temp replacement
|
||||
|
||||
const colRegex = /^([\s\S]+?)(?:\s+collate\s+([\w]+))?(?:\s+(asc|desc))?$/gim;
|
||||
const colRegex = /^([\s\S]+?)(?:\s+collate\s+([\w]+))?(?:\s+(asc|desc))?\s*$/gi;
|
||||
const colMatches = colRegex.exec(col);
|
||||
if (colMatches?.length != 4) {
|
||||
continue;
|
||||
|
||||
Reference in new issue
Block a user