When a field is a foreign key on one table, there's an implication that it 
is a primary key on another table.  And it is generally accepted convention 
that primary keys are ints, except when they aren't! 
[http://book.cakephp.org/1.3/view/1016/Using-UUIDs-as-Primary-Keys]

Since a UUID is not an int, you might think that CakePHP would need to 
handle non-ints as foreign keys.  However, a key is only recognised as a 
UUID when it is defined as CHAR(36) or BINARY(36).

You may have found a bug.  Then next bit to work out is what SQL is 
generated that is causing the error, and then where in the MS SQL driver 
that is getting generated.  It also might help if you mention what version 
of CakePHP you are using.

Regards
Reuben Helms

On Thursday, 15 November 2012 08:03:41 UTC+10, Tomas wrote:
>
> Hi!!
> I work ussualy with mysql and I work in cake long time, but now with MS 
> SQL, I get strange error on very simple thing - *view*, *index*, 
> *edit*methods within 
> *SCAFFOLD mode.*
> *
>
> Error: *SQLSTATE[22018]: [Microsoft][SQL Server Native Client 11.0][SQL 
> Server]Conversion failed when converting the varchar value 'G12345' to data 
> type int.
>
> There is a table called *'item'*, which has a field GLID - vachar(20). 
> Simple field, not even primary key. the only thing is that it is in 
> relation with other table 'material' with same properties. E.g. 'item' 
> hasMany 'material' AND 'material' belongsTo 'item'.
>
> Can I link varchars as foreign keys in cake?? Because if I edit the field 
> values and I remove letter 'G' ... 'G12345' >> '12345' then it works ok!! 
> why cake converts something to int??
>
>
> Any idea?
>
> Thank you
> Tomas
>

-- 
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.


Reply via email to