@galadrim/galadmin 0.1.130 → 0.1.132
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/dist/api.js +0 -4
- package/dist/api.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/dbManager.js +29 -1
- package/dist/utils/dbManager.js.map +1 -1
- package/package.json +1 -1
- package/src/api.ts +0 -3
- package/src/front/build/asset-manifest.json +3 -3
- package/src/front/build/index.html +1 -1
- package/src/front/build/static/js/{main.cb304071.js → main.c8b607ef.js} +3 -3
- package/src/front/build/static/js/{main.cb304071.js.map → main.c8b607ef.js.map} +1 -1
- package/src/front/src/utils/getFormattedValue.js +1 -1
- package/src/utils/dbManager.ts +37 -1
- /package/src/front/build/static/js/{main.cb304071.js.LICENSE.txt → main.c8b607ef.js.LICENSE.txt} +0 -0
|
@@ -46,7 +46,7 @@ export default (column, record, config, onTable) => {
|
|
|
46
46
|
} else if (column.dataType === "select" && column.options && column.options.constructor == Object) {
|
|
47
47
|
return <div>{column.options[record[column.name]]}</div>
|
|
48
48
|
} else if (column.dataType === "string[]") {
|
|
49
|
-
return <div>{record[column.name]
|
|
49
|
+
return <div>{record[column.name]?.join(", ")}</div>
|
|
50
50
|
} else {
|
|
51
51
|
return <div>{record[column.name]}</div>
|
|
52
52
|
}
|
package/src/utils/dbManager.ts
CHANGED
|
@@ -31,6 +31,42 @@ function convertQuery(mysqlQuery, params) {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
function quotePostgresQuery(query) {
|
|
35
|
+
query = query.replace(/`/g, '"');
|
|
36
|
+
|
|
37
|
+
const reservedWords = ["1", "COUNT", "*", "UPDATE", "SELECT", "SET", "=", "INSERT", "DELETE", "FROM", "WHERE", "AND", "OR", "JOIN", "ON", "AS", "IN", "LIKE", "EXISTS", "ALL", "ANY", "NOT", "NULL", "TRUE", "FALSE", "GROUP", "BY", "ORDER", "LIMIT", "OFFSET", "DESC"]
|
|
38
|
+
|
|
39
|
+
const wordsToAddQuotes = new Set()
|
|
40
|
+
const parts = query.split(/[ \(\)]/);
|
|
41
|
+
|
|
42
|
+
let inString = false;
|
|
43
|
+
|
|
44
|
+
for (let i = 0; i < parts.length; i++) {
|
|
45
|
+
const part = parts[i].trim();
|
|
46
|
+
if (!part) {
|
|
47
|
+
continue
|
|
48
|
+
}
|
|
49
|
+
if (part.split(/['"]/).length % 2 === 0) {
|
|
50
|
+
inString = !inString;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (inString || part.startsWith("$") || part.includes("'") || part.includes('"') || reservedWords.includes(part.toUpperCase())) {
|
|
54
|
+
|
|
55
|
+
} else {
|
|
56
|
+
for (let x of part.split(".")) {
|
|
57
|
+
wordsToAddQuotes.add(x)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let newQuery = query;
|
|
63
|
+
for (let word of wordsToAddQuotes) {
|
|
64
|
+
newQuery = newQuery.replace(new RegExp(`(?<!["\'])\\b${word}\\b(?!["\'])`, 'g'), `"${word}"`)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return newQuery;
|
|
68
|
+
}
|
|
69
|
+
|
|
34
70
|
export default class dbManager {
|
|
35
71
|
_db;
|
|
36
72
|
dbType;
|
|
@@ -66,7 +102,7 @@ export default class dbManager {
|
|
|
66
102
|
return new Promise((resolve, reject) => {
|
|
67
103
|
if (this.dbType === "POSTGRESQL") {
|
|
68
104
|
const result = convertQuery(queryString, args);
|
|
69
|
-
queryString = result.pgQuery;
|
|
105
|
+
queryString = quotePostgresQuery(result.pgQuery);
|
|
70
106
|
args = result.pgParams;
|
|
71
107
|
}
|
|
72
108
|
this._db.query(queryString, args, (a, b, c) => {
|
/package/src/front/build/static/js/{main.cb304071.js.LICENSE.txt → main.c8b607ef.js.LICENSE.txt}
RENAMED
|
File without changes
|