CartoDB-SQL-API/lib/utils/query-may-write.js

15 lines
519 B
JavaScript
Raw Normal View History

'use strict';
2019-12-24 01:19:08 +08:00
var sqlQueryMayWriteRegex = new RegExp('\\b(alter|insert|update|delete|create|drop|reindex|truncate|refresh)\\b', 'i');
/**
* This is a fuzzy check, the return could be true even if the query doesn't really write anything. But you can be
* pretty sure of a false return.
*
* @param sql The SQL statement to check against
* @returns {boolean} Return true of the given query may write to the database
*/
2019-12-24 01:19:08 +08:00
module.exports = function queryMayWrite (sql) {
return sqlQueryMayWriteRegex.test(sql);
2015-12-04 01:45:12 +08:00
};