deconstruct unknown date/time arrays to be able to properly use them in ... #842

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
5 participants
lib/Cake/Model/Model.php
@@ -1210,14 +1210,26 @@ protected function _normalizeXmlData(array $xml) {
*
* @param string $field The name of the field to be deconstructed
* @param array|object $data An array or object to be deconstructed into a field
+ * @param string $type The field type to manually overwrite the automatic detection or schema default
@ADmad

ADmad Sep 14, 2012

Member

s/overwrite/override

+ if (isset($data['hour']) || isset($data['min']) || isset($data['sec'])) {
+ $type .= 'time';
+ }
+ }
@markstory

markstory Sep 14, 2012

Owner

I dunno about this. Seems like moar magic which has the potential of going wrong. Like ADmad said in the lighthouse ticket couldn't you just setup the schema or specify the types when using deconstruct. In the past when we've had code that does guessing it generally ends up being wrong.

@@ -1167,6 +1167,68 @@ public function testDeconstructFieldsDateTime() {
}
+/**
+ * testDeconstructFields with unkown datetime fields
@shama

shama Sep 14, 2012

Contributor

Small typo /unkown/unknown/ :)

@lorenzo

lorenzo Sep 14, 2012

Owner

I agree with mark, adding more magic like this is not going to be good in
the long term. You can just easily override getColumnType or your schema to
return whatever you want.

Member

ADmad commented Sep 14, 2012

Since none of the devs seem to be in favor of this, I am closing the PR and the ticket.

@ADmad ADmad closed this Sep 14, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment