Skip to content

fix(PRB-1528): apply insensitive case on SQL rule match #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ function mixinMigration(PostgreSQL) {
if (self.idColumn(model) === actualField.column) {
return;
}
if (actualFieldNotPresentInModel(actualField, model)) {
sql.push('DROP COLUMN ' + self.escapeName(actualField.column));
}
// if (actualFieldNotPresentInModel(actualField, model)) {
// sql.push('DROP COLUMN ' + self.escapeName(actualField.column));
// }
});
if (sql.length > 0) {
sql = [sql.join(', ')];
Expand Down Expand Up @@ -559,7 +559,7 @@ function mixinMigration(PostgreSQL) {
propName = propName && self.propertyName(model, propName[1]) || null;
if (!(indexNames.indexOf(indexName) > -1) && !(propName && m.properties[propName] &&
m.properties[propName].index)) {
sql.push('DROP INDEX ' + self.escapeName(indexName));
// sql.push('DROP INDEX ' + self.escapeName(indexName));
} else {
// The index was found, verify that database matches what we're expecting.
// first: check single column indexes.
Expand All @@ -571,7 +571,7 @@ function mixinMigration(PostgreSQL) {
!((!si.type || si.type === ai[indexName].type) && (!si.unique || si.unique === ai[indexName].unique))
) {
// Drop the index if the type or unique differs from the actual table
sql.push('DROP INDEX ' + self.escapeName(indexName));
// sql.push('DROP INDEX ' + self.escapeName(indexName));
delete ai[indexName];
}
}
Expand All @@ -597,7 +597,7 @@ function mixinMigration(PostgreSQL) {
}

if (!identical) {
sql.push('DROP INDEX ' + self.escapeName(indexName));
// sql.push('DROP INDEX ' + self.escapeName(indexName));
delete ai[indexName];
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/postgresql.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ PostgreSQL.prototype.executeSQL = function(sql, params, options, callback) {
debug('SQL: %s', sql);
}

if (sql && sql.match('UPDATE') && !sql.match('WHERE') && self.settings.blockUpdateWithoutWhere) {
if (sql && sql.match(/UPDATE/i) && !sql.match(/WHERE/i) && self.settings.blockUpdateWithoutWhere) {
return process.nextTick(function() {
callback(new Error(g.f('Você está executando um update sem WHERE. Corrija essa query, meu caro:',sql)));
});
Expand Down