diff --git a/console/src/components/Services/Data/utils.js b/console/src/components/Services/Data/utils.js index ceb6e7a4a51..3f6baa3206a 100644 --- a/console/src/components/Services/Data/utils.js +++ b/console/src/components/Services/Data/utils.js @@ -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