From 48477211d42aa6430519b20799c40046fe9cd375 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Thu, 14 Dec 2023 18:03:39 -0500 Subject: [PATCH] fix: apply setters in castForQuery with uuid Re: #14114 --- lib/schema/uuid.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/schema/uuid.js b/lib/schema/uuid.js index 41ab1f60e49..aa72c42107f 100644 --- a/lib/schema/uuid.js +++ b/lib/schema/uuid.js @@ -344,8 +344,15 @@ SchemaUUID.prototype.castForQuery = function($conditional, val, context) { if (!handler) throw new Error('Can\'t use ' + $conditional + ' with UUID.'); return handler.call(this, val, context); - } else { - return this.cast(val); + } + + try { + return this.applySetters(val, context); + } catch (err) { + if (err instanceof CastError && err.path === this.path && this.$fullPath != null) { + err.path = this.$fullPath; + } + throw err; } };