Tuesday, December 30, 2014

Re: 1.3 Migration Question re:NULL and Defaults

Thanks again, yes this is what I am seeing and is consistent with the idea that the old code did not submit a NULL field.

As notated above the "save" statement in the controller has no parms other than $this->data - when the field has nothing assigned to it cakePHP 1.3.20 sets it to NULL - although this exact same thing occurs under the old 1.2 code, in 1.2 the field set to NULL is not part of the INSERT operation, whereas in 1.3 it is.

So the old app code that essentially has no parm validation on the form does not work in 1.3. Funny thing is I guess they were relying on mySQL to convert the NULL to the default when what they were really relying on was cakePHP recognizing the NULL and stripping that column from the INSERT request thus allowing the default in the DB to set the default value.

I guess what is now needed is to set your own default value - I wonder if there is an easy way to do this in the model somewhere?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: