diff --git a/lib/waterline/methods/archive.js b/lib/waterline/methods/archive.js index 9b5020036..07ee6a593 100644 --- a/lib/waterline/methods/archive.js +++ b/lib/waterline/methods/archive.js @@ -216,6 +216,8 @@ module.exports = function archive(/* criteria, explicitCbMaybe, metaContainer */ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + var defaultWhereCriteria = query.criteria.where; + // ╔═╗═╗ ╦╔═╗╔═╗╦ ╦╔╦╗╔═╗ ┌─┐┬┌┐┌┌┬┐ ┌─┐ ┬ ┬┌─┐┬─┐┬ ┬ // ║╣ ╔╩╦╝║╣ ║ ║ ║ ║ ║╣ ├┤ ││││ ││ │─┼┐│ │├┤ ├┬┘└┬┘ // ╚═╝╩ ╚═╚═╝╚═╝╚═╝ ╩ ╚═╝ └ ┴┘└┘─┴┘ └─┘└└─┘└─┘┴└─ ┴ @@ -240,6 +242,8 @@ module.exports = function archive(/* criteria, explicitCbMaybe, metaContainer */ }); });//∞ + query.criteria.where = defaultWhereCriteria; + // ╔═╗═╗ ╦╔═╗╔═╗╦ ╦╔╦╗╔═╗ ┌─┐┬─┐┌─┐┌─┐┌┬┐┌─┐┌─┐┌─┐┌─┐┬ ┬ ┌─┐ ┬ ┬┌─┐┬─┐┬ ┬ // ║╣ ╔╩╦╝║╣ ║ ║ ║ ║ ║╣ │ ├┬┘├┤ ├─┤ │ ├┤ ├┤ ├─┤│ ├─┤ │─┼┐│ │├┤ ├┬┘└┬┘ // ╚═╝╩ ╚═╚═╝╚═╝╚═╝ ╩ ╚═╝ └─┘┴└─└─┘┴ ┴ ┴ └─┘└─┘┴ ┴└─┘┴ ┴ └─┘└└─┘└─┘┴└─ ┴ @@ -255,6 +259,8 @@ module.exports = function archive(/* criteria, explicitCbMaybe, metaContainer */ delete query.criteria.select; delete query.criteria.omit; + query.criteria.where = defaultWhereCriteria; + // ╔═╗═╗ ╦╔═╗╔═╗╦ ╦╔╦╗╔═╗ ┌┬┐┌─┐┌─┐┌┬┐┬─┐┌─┐┬ ┬ ┌─┐ ┬ ┬┌─┐┬─┐┬ ┬ // ║╣ ╔╩╦╝║╣ ║ ║ ║ ║ ║╣ ││├┤ └─┐ │ ├┬┘│ │└┬┘ │─┼┐│ │├┤ ├┬┘└┬┘ // ╚═╝╩ ╚═╚═╝╚═╝╚═╝ ╩ ╚═╝ ─┴┘└─┘└─┘ ┴ ┴└─└─┘ ┴ └─┘└└─┘└─┘┴└─ ┴ diff --git a/lib/waterline/methods/create.js b/lib/waterline/methods/create.js index c6c60742a..645623652 100644 --- a/lib/waterline/methods/create.js +++ b/lib/waterline/methods/create.js @@ -157,6 +157,7 @@ module.exports = function create(newRecord, explicitCbMaybe, metaContainer) { name: 'UsageError', code: e.code, details: e.details, + attrName: e.attrName, message: 'Invalid new record.\n'+ 'Details:\n'+ diff --git a/lib/waterline/utils/query/forge-stage-two-query.js b/lib/waterline/utils/query/forge-stage-two-query.js index 6fd6ea1f6..7fe5eda74 100644 --- a/lib/waterline/utils/query/forge-stage-two-query.js +++ b/lib/waterline/utils/query/forge-stage-two-query.js @@ -1254,10 +1254,10 @@ module.exports = function forgeStageTwoQuery(query, orm) { case 'E_TYPE': case 'E_REQUIRED': case 'E_VIOLATES_RULES': - throw buildUsageError('E_INVALID_NEW_RECORD', e.message, query.using); + throw buildUsageError('E_INVALID_NEW_RECORD', e.message, query.using, e.attrName); case 'E_HIGHLY_IRREGULAR': - throw buildUsageError('E_INVALID_NEW_RECORD', e.message, query.using); + throw buildUsageError('E_INVALID_NEW_RECORD', e.message, query.using, e.attrName); default: throw e; } diff --git a/lib/waterline/utils/query/private/build-usage-error.js b/lib/waterline/utils/query/private/build-usage-error.js index fdc2c15d8..2511d82fd 100644 --- a/lib/waterline/utils/query/private/build-usage-error.js +++ b/lib/waterline/utils/query/private/build-usage-error.js @@ -153,7 +153,7 @@ var USAGE_ERR_MSG_TEMPLATES = { * > this utility adds another internal item to the top of the trace. */ -module.exports = function buildUsageError(code, details, modelIdentity) { +module.exports = function buildUsageError(code, details, modelIdentity, attrName) { // Sanity checks if (!_.isString(code)) { @@ -187,7 +187,8 @@ module.exports = function buildUsageError(code, details, modelIdentity) { name: 'UsageError', code: code, details: details, - modelIdentity: modelIdentity + modelIdentity: modelIdentity, + attrName: attrName }, err); // That's it! diff --git a/lib/waterline/utils/query/private/normalize-where-clause.js b/lib/waterline/utils/query/private/normalize-where-clause.js index 2e96b981f..67e81ba2a 100644 --- a/lib/waterline/utils/query/private/normalize-where-clause.js +++ b/lib/waterline/utils/query/private/normalize-where-clause.js @@ -516,7 +516,9 @@ module.exports = function normalizeWhereClause(whereClause, modelIdentity, orm, // Normalize the constraint itself. // (note that this checks the RHS, but it also checks the key aka constraint target -- i.e. the attr name) try { - branch[soleBranchKey] = normalizeConstraint(branch[soleBranchKey], soleBranchKey, modelIdentity, orm, meta); + if( '$text' !== soleBranchKey ) { + branch[soleBranchKey] = normalizeConstraint(branch[soleBranchKey], soleBranchKey, modelIdentity, orm, meta); + } } catch (e) { switch (e.code) {