Are we missing out on a bunch of bugs in Cake due to poor management
of tickets?

This here is a confirmed bug. I have posted the fix. The ticket gets
deleted with no resolution?

I'm GOBSMACKED!!!!

Well if anyone wants patches for broken bits of CakePHP, I'll post
them here from now-on rather then to the ticket system.

-Ben






Ticket #4219 (reopened Bug)
Opened 12 hours ago

Last modified 8 hours ago
dbo_source getConstraint hasAndBelongsToMany with primaryKey fails
Reported by: mryellow Assigned to:
Priority: High Milestone:
Component: Databases Version:
Severity: Normal Keywords:
Cc:  PHP Version: n/a
Version From VERSION.txt: 1.2.0.6311 beta

Description  ¶
Tags primaryKey = "tag" Article with = TagsUsersArticle?

Generates [TagsUsersArticle?.tag_id] =>
{$cakeIdentifier[TagArticle?.tag]$} in dbo_source.

The tag_id is wrong as Tags model sets it's PK as "tag".

-Ben

Change History
02/24/08 19:40:33 changed by mryellow  ¶
Problem starts with associationForeignKey being setup wrong.

case 'associationForeignKey':

if (!empty($this->{$class}->primaryKey)) {

$data = $this->{$class}->primaryKey;

} else {

$data = Inflector::singularize($this->{$class}->table) . '_id';

}

-Ben

02/24/08 23:21:19 changed by nate  ¶
status changed from new to closed.
resolution set to needmoreinfo.
This isn't really enough information to reproduce the issue. Please
attach all relevant model files and related schemas. A unit test might
also be nice.

02/24/08 23:59:55 changed by mryellow  ¶
status changed from closed to reopened.
resolution deleted.
Closed already??? I've patched it and moved on.....

When using "with" and a non-numeric key in a 3 way join.

It would be duplicatable with a 2 way join also, the key factor being
the non-numeric primarykey specified in the model. The primaryKey
variable is used in 99% of the code, except for the bit I've
highlighted in model.php. case 'associationForeignKey': around line
710.

Thus saving a relationship into a HABTM table with a foreignkey "tag"
the code generated would instead yield "tag_id" (a non-existent
field).

The above code patch failed when using some other types of
relationships. Add the check for "id" as the primaryKey value.

[code] case 'associationForeignKey':

if (!empty($this->{$class}->primaryKey) && $this->{$class}-
>primaryKey != 'id') {

$data = $this->{$class}->primaryKey;

} else {

$data = Inflector::singularize($this->{$class}->table) . '_id';

}

/code

-Ben

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to