Ticket #438 (closed defect: fixed)

Opened 23 months ago

Last modified 6 months ago

changed from Relationship of tables with multiple primary keys not populated properly (with test case)

Reported by: tamcy Owned by: zYne-
Priority: major Milestone: 2.0.0 (OLD)
Component: Query/Hydration Version:
Severity: Keywords:
Cc: Has Test: no
Status: Pending Core Response Has Patch: no

Description (last modified by solar) (diff)

The test case shows a Student table, a Course table and a StudentCourse table. A student may take multiple courses.

The primary key order in StudentCourse is (student_id, course_id).

When I select records from StudentCourse, the course object primary key is mistakenly overwritten by the student primary key, i.e. $course->id now equals to $studentCourse->student_id, which should to be $studentCourse->course_id (but the _id['c_id'] instance of the course is correct. Only the data['c_id'] is wrong.

Attachments

438TestCase.php (5.2 KB) - added by tamcy 19 months ago.
updated 2 dec 2007

Change History

Changed 23 months ago by romanb

  • milestone set to 1.0

Changed 20 months ago by jwage

  • owner changed from somebody to zYne-

I went to look at applying your patch but Record.php has changed a lot since you submitted it and I couldn't get it to apply at all. Can you confirm that this is still an issue? Can you commit your failing test case to the trunk tests if it is still an issue.

Changed 19 months ago by tamcy

  • summary changed from Relationship of tables with multiple primary keys not populated properly (with test case) to [3270] by tamcy

I've just updated the related test case [3270]. The relationship itself is correct in the first case (relationship fetched in multiple queries), but an exception is thrown when running the second query, because the table columns are joined using their alias, not the real column name: (Note the column names in the LEFT JOIN part)

SELECT t.sc_student_id AS t__sc_student_id, t.sc_course_id AS t__sc_course_id, t.sc_remark  AS t__sc_remark , t2.s_id AS t2__s_id, t2.s_name AS t2_
_s_name, t3.c_id AS t3__c_id, t3.c_name AS t3__c_name FROM t438_student_course t LEFT JOIN t438_student_record t2 ON t.student_id = t2.id LEFT JOIN t438_course
t3 ON t.course_id = t3.id WHERE (t.sc_student_id = ? AND t.sc_course_id = ?)

Changed 19 months ago by tamcy

  • summary changed from [3270] by tamcy to changed from Relationship of tables with multiple primary keys not populated properly (with test case)

don't know why summary is changed..

Changed 19 months ago by tamcy

updated 2 dec 2007

Changed 19 months ago by tamcy

Deleted the patch that doesn't work anymore. Update test case both in this ticket and in trunk. The problem still persists.

Changed 19 months ago by tamcy

Interestingly, the suggested patch in #638 also fixes this problem.

Changed 19 months ago by tamcy

run.php result against latest revision [3387]

Test before the patch:
====================
Tested: 156 test cases
Successes: 2390 passes.
Failures: 18 fails.
55593.2890625

Doctrine_Migration_Mysql_TestCase : method testMigration failed on line 77 server does not exist.
====================
Tested: 156 test cases
Successes: 2395 passes.
Failures: 13 fails.
55598.8359375

(Addresses the 2 failing cases in #438; and 3 in #638)

Changed 19 months ago by tamcy

Oops, that "Doctrine_Migration_Mysql_TestCase..." should be "Test after the patch"

Changed 17 months ago by romanb

  • component changed from general to Query/Hydration

Changed 17 months ago by jwage

  • status changed from new to closed
  • resolution set to fixed

(In [3848]) fixes #438 in 0.10 branch. Related to #438

Changed 16 months ago by anonymous

  • milestone 1.0 deleted

Milestone 1.0 deleted

Changed 13 months ago by airforce1

Changed 6 months ago by solar

  • has_patch unset
  • mystatus set to Pending Core Response
  • description modified (diff)
  • has_test unset

Place of origin:Guangdong ChinaModel? No:YL-S01Payment Terms:L/C,T/T,Western UnionMinimum? Order Quantity:500 Piece/PiecesSupply Ability:100000 Piece/Pieces per DayPackage:Blister pack

 http://www.solar-water-heaters.com.cn/

Note: See TracTickets for help on using tickets.