Ticker

6/recent/ticker-posts

cakePHP HABTM : not support for foreign key with string type and length 32 | UUID

In cakePHP,

I have noticed in my recent project, if I use relation table such that,
the foreign key is of type string (uuid) and is of length 32,
it does not support it at all.


When I drilled down the model.php of cake lib.

I found the surprise at line 1408

if ((is_string($row) && (strlen($row) == 36 || strlen($row) == 16)) || is_numeric($row)) {

that means for string type columns as foreign key, it supports on lengths 36 and 16.

I changed the code lib a bit to work my project like 


if ((is_string($row) && (strlen($row) == 36 || strlen($row) == 32 || strlen($row) == 16)) || is_numeric($row)) {

I'll see the reason in future exercise why its not working that ways, and why this limitation is there.

--
Regards,
Pavan Agrawal

Post a Comment

0 Comments