console: fix dropping Postgres dependencies (close #5993) (#5998)

This commit is contained in:
Sooraj 2020-10-15 13:58:56 +05:30 committed by GitHub
parent f319b02766
commit 56063515e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -793,7 +793,12 @@ WHERE
export const isColTypeString = colType =>
['text', 'varchar', 'char', 'bpchar', 'name'].includes(colType);
const isCascadable = sql => {
const regex = new RegExp(/(\s|^)drop\s/i); // all queries with drop (with space on both sides Ie:this would ignore names matches with "" or prefix/suffix)
return regex.test(sql);
};
const cascadePGSqlQuery = sql => {
if (!isCascadable(sql)) return sql;
if (sql[sql.length - 1] === ';')
return sql.substr(0, sql.length - 1) + ' CASCADE;';
// SQL might have a " at the end