Wednesday, October 29, 2008

Re: HABTM in rc3 need now field id in link table.

I did a lot of work and research into this issue of which I thought
martin.westin responded to.

A primary id field is required in order for the current code to work.
I have some changes and test that could be made to the core that would
correct the problems that exist when an id key is not present.
I had posted earlier this month some questions to the core team of how
we should proceed.

Is this not the same problem as this post:
http://groups.google.com/group/cake-php/browse_thread/thread/5d5f3aea37a8b950/c61b3d39e217c2c6#c61b3d39e217c2c6

The problem as I recall it is the delete that is called while doing an
update does not pass the second parameter to the model delete function
for cascade.
Plus if there is no id then it builds a condition based on the wrong
side of the relation. The combination of the to conditions causes all
relations to be dropped except for the one your saving.

I'll check this post again later today to see how we want to proceed,
their were some conversations that took place on the IRC channel in
regards to this and the consensus was the mapping tables need a
primary id key field. So I never bothered with adding my tests and
code changes.
At the very least maybe we should add some code to throw an error or
warning when a mapping table has no id.

On Oct 29, 2:34 am, "martin.westin...@gmail.com"
<martin.westin...@gmail.com> wrote:
> Teknoid, you may be right but the fixtures for the tests in the core
> create loin tables without a pk.
> E.g:
> var $fields = array(
>     'article_id' => array('type' => 'integer', 'null' => false),
>     'tag_id' => array('type' => 'integer', 'null' => false),
>     'indexes' => array('UNIQUE_TAG' => array('column'=>
> array('article_id', 'tag_id'), 'unique'=>1))
> );
>
> /Martin
>
> On Oct 28, 3:56 pm, Alexandru <alexandru...@gmail.com> wrote:
>
> > no no in rc2 this was on manual
> > Recipe HABTM Tag  => recipes_tags.recipe_id, recipes_tags.tag_id
> > BUT now they changed in manual and put this
> > Recipe HABTM Tag  => id,recipes_tags.recipe_id, recipes_tags.tag_id
>
> > now i know for sure it is NOT a BUG.
>
> > TOPIC CLOSED
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: