Skip to content

Commit

Permalink
Fixes #10532, fixes #1780, fixes #3256, fixes #1652, fixes #760, fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgutierrez committed Jun 25, 2015
1 parent dbfef88 commit ab6de6e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
- Values in LIMIT/OFFSET clause are now passed using bound parameters in PHQL
- Allowing late state binding in both Simple/Complex results to allow override Mvc\Model::cloneResultMap
- Added method `distinct()` in `Phalcon\Mvc\Model\Criteria` [#10536](https://github.com/phalcon/cphalcon/issues/10536)
- Added global setting orm.ignore_unknown_columns to ignore unexpected columns when hydrating instances in the ORM
This fixes extra auxiliar columns used in Db\\Adapter\\Pdo\\Oracle

# 2.0.3 (2015-06-10)
- Added support for Behaviors in Phalcon\Mvc\Collection
Expand Down
4 changes: 4 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
"orm.cast_on_hydrate": {
"type": "bool",
"default": false
},
"orm.ignore_unknown_columns": {
"type": "bool",
"default": false
}
},
"destructors": {
Expand Down
17 changes: 14 additions & 3 deletions phalcon/mvc/model.zep
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,11 @@ abstract class Model implements EntityInterface, ModelInterface, ResultInterface

// Every field must be part of the column map
if !fetch attribute, columnMap[key] {
throw new Exception("Column '" . key . "' doesn't make part of the column map");
if !globals_get("orm.ignore_unknown_columns") {
throw new Exception("Column '" . key . "' doesn't make part of the column map");
} else {
continue;
}
}

if typeof attribute != "array" {
Expand Down Expand Up @@ -2897,7 +2901,7 @@ abstract class Model implements EntityInterface, ModelInterface, ResultInterface
}
}

if success === false {
if success === false {
this->_cancelOperation();
} else {
this->fireEvent("afterSave");
Expand Down Expand Up @@ -4286,7 +4290,7 @@ abstract class Model implements EntityInterface, ModelInterface, ResultInterface
{
var disableEvents, columnRenaming, notNullValidations,
exceptionOnFailedSave, phqlLiterals, virtualForeignKeys,
lateStateBinding, castOnHydrate;
lateStateBinding, castOnHydrate, ignoreUnknownColumns;

/**
* Enables/Disables globally the internal events
Expand Down Expand Up @@ -4343,6 +4347,13 @@ abstract class Model implements EntityInterface, ModelInterface, ResultInterface
if fetch castOnHydrate, options["castOnHydrate"] {
globals_set("orm.cast_on_hydrate", castOnHydrate);
}

/**
* Allows to ignore unknown columns when hydrating objects
*/
if fetch ignoreUnknownColumns, options["ignoreUnknownColumns"] {
globals_set("orm.ignore_unknown_columns", ignoreUnknownColumns);
}
}

/**
Expand Down

0 comments on commit ab6de6e

Please sign in to comment.