From 3cc590186a5c427811d42a4fda2d655d284f5d29 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 19 Dec 2025 08:58:34 +0000 Subject: [PATCH] Add property conflict detection to JS ORM model hydration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/RSpade/Core/Js/Rsx_Js_Model.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/RSpade/Core/Js/Rsx_Js_Model.js b/app/RSpade/Core/Js/Rsx_Js_Model.js index d4aef06af..bebabbf90 100755 --- a/app/RSpade/Core/Js/Rsx_Js_Model.js +++ b/app/RSpade/Core/Js/Rsx_Js_Model.js @@ -29,6 +29,27 @@ class Rsx_Js_Model { // This constructor filters out the __MODEL marker that was used to identify which class // to instantiate, keeping only the actual data properties on the instance. const { __MODEL, ...modelData } = data; + + // Check for property conflicts before assignment + const modelName = __MODEL || this.constructor.name; + for (const key in modelData) { + if (key in this) { + if (typeof this[key] === 'function') { + throw new Error( + `Model property conflict: "${key}" from server response would overwrite ` + + `a method on ${modelName}. Check the PHP model's fetch() or toArray() method ` + + `to see if "${key}" should be excluded or renamed. If the JS method ${key}() ` + + `is computing a value the server now provides, remove the JS method.` + ); + } else { + throw new Error( + `Model property conflict: "${key}" already exists on ${modelName} ` + + `and would be overwritten by server response data.` + ); + } + } + } + Object.assign(this, modelData); }