Skip to content

Commit afa744b

Browse files
fixed indexedDB queries + handle drop database queries
1 parent 2112ea4 commit afa744b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

client/packages/lowcoder/src/comps/queries/httpQuery/alasqlQuery.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export class AlaSqlQuery extends AlaSqlTmpQuery {
4343

4444
const sqlQuery = children.sql.children.text.unevaledValue.replace(/ +/g, ' ');
4545
const isCreateDBQuery = sqlQuery.toUpperCase().startsWith('CREATE DATABASE');
46+
const isDropDBQuery = sqlQuery.toUpperCase().startsWith('DROP DATABASE');
4647

4748
return async (p: { args?: Record<string, unknown> }): Promise<QueryResult> => {
4849
try {
@@ -52,8 +53,11 @@ export class AlaSqlQuery extends AlaSqlTmpQuery {
5253
if (databaseType === 'localDB' && isCreateDBQuery) {
5354
const updatedQuery = `${sqlQuery.slice(0, 6)} ${selectedDB} ${sqlQuery.slice(6)}`;
5455
const tableName = updatedQuery.split(' ').pop()?.replace(';', '');
55-
result = alasql(updatedQuery);
56-
result = alasql(`ATTACH ${selectedDB} DATABASE ${tableName};`);
56+
result = await alasql.promise(updatedQuery);
57+
result = await alasql.promise(`ATTACH ${selectedDB} DATABASE ${tableName};`);
58+
} else if (databaseType === 'localDB' && isDropDBQuery) {
59+
const updatedQuery = `${sqlQuery.slice(0, 4)} ${selectedDB} ${sqlQuery.slice(4)}`;
60+
result = await alasql(updatedQuery);
5761
} else {
5862
let segments = getDynamicStringSegments(sqlQuery);
5963
let dataArr: any = [];
@@ -65,7 +69,7 @@ export class AlaSqlQuery extends AlaSqlTmpQuery {
6569
}
6670
return segment;
6771
})
68-
result = alasql(segments.join(' '), dataArr);
72+
result = await alasql.promise(segments.join(' '), dataArr);
6973
}
7074

7175
return {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy