From 5eb891f414e4a3061a0faaa34fde2113225d9e0c Mon Sep 17 00:00:00 2001 From: Cameron Hall Date: Thu, 24 Oct 2019 22:23:56 +1100 Subject: [PATCH] [#14485] ignore_unknown_columns global is respected by update and insert --- CHANGELOG-4.0.md | 1 + phalcon/Mvc/Model.zep | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG-4.0.md b/CHANGELOG-4.0.md index 7dff97b155b..147024dfcc6 100644 --- a/CHANGELOG-4.0.md +++ b/CHANGELOG-4.0.md @@ -50,6 +50,7 @@ - Fixed `Phalcon\Translate\*` aligning `parameters` as `array` with the interpolator calls. [#14477](https://github.com/phalcon/cphalcon/pull/14477) - Fixed `Phalcon\Storage\AdapterFactory:newInstance` to return the correct interface [#14481](https://github.com/phalcon/cphalcon/issues/14481) - Fixed `Phalcon\Mvc\Dispatcher:forward` to accept an array vs a mixed variable [#14481](https://github.com/phalcon/cphalcon/issues/14481) +- Fixed `Phalcon\Mvc\Model::_doLowUpdate` and `Phalcon\Mvc\Model::_doLowInsert` throwing errors about column mapping when `phalcon.orm.ignore_unknown_columns` is set `On` [#14485](https://github.com/phalcon/cphalcon/issues/14485) ## Removed - Removed `Phalcon\Application\AbstractApplication::handle()` as it does not serve any purpose and causing issues with type hinting. [#14407](https://github.com/phalcon/cphalcon/pull/14407) diff --git a/phalcon/Mvc/Model.zep b/phalcon/Mvc/Model.zep index b43b4d04a9a..cfe2c049d47 100644 --- a/phalcon/Mvc/Model.zep +++ b/phalcon/Mvc/Model.zep @@ -3715,9 +3715,11 @@ abstract class Model extends AbstractInjectionAware implements EntityInterface, */ if typeof columnMap == "array" { if unlikely !fetch attributeField, columnMap[field] { - throw new Exception( - "Column '" . field . "' isn't part of the column map" - ); + if unlikely !globals_get("orm.ignore_unknown_columns") { + throw new Exception( + "Column '" . field . "' isn't part of the column map" + ); + } } } else { let attributeField = field; @@ -4437,9 +4439,11 @@ abstract class Model extends AbstractInjectionAware implements EntityInterface, for field in notNull { if typeof columnMap == "array" { if unlikely !fetch attributeField, columnMap[field] { - throw new Exception( - "Column '" . field . "' isn't part of the column map" - ); + if unlikely !globals_get("orm.ignore_unknown_columns") { + throw new Exception( + "Column '" . field . "' isn't part of the column map" + ); + } } } else { let attributeField = field;