#6245: HABTM primaryKey identified in one direction only, bad DELETE queries ---------------------------------+------------------------------------------ Reporter: cuppett | Owner: Type: Test Case | Status: reopened Priority: High | Milestone: 1.2.x.x Component: General | Version: 1.2 Final Severity: Major | Resolution: Keywords: HABTM primaryKey | Php_version: PHP 5 Cake_version: 1.2.2.8120 | ---------------------------------+------------------------------------------ Comment (by cuppett):
Okay. Have testcase. Thanks for the pointers today![[BR]] [[BR]] The problem seems to be database specific. Postgres exhibits the problem, MySQL does not. I do not know about other engines.[[BR]] [[BR]] Using MySQL, the test passes and I see this:[[BR]] [[BR]] Query #12: DELETE `PostsTag` FROM `posts_tags` AS `PostsTag` WHERE `PostsTag`.`tag_id` = '1' AND `PostsTag`.`post_id` IN (1, 2)[[BR]] [[BR]] Query #17: DELETE `PostsTag` FROM `posts_tags` AS `PostsTag` WHERE `PostsTag`.`post_id` = 2 AND `PostsTag`.`tag_id` = ('3')[[BR]] [[BR]] Using PostgreSQL, the test fails. I get the following (unrelated?) error:[[BR]] [[BR]] Query #19: SELECT "Tag"."id" AS "Tag__id", "Tag"."tag" AS "Tag__tag", "Tag"."created" AS "Tag__created", "Tag"."updated" AS "Tag__updated", "PostsTag"."post_id" AS "PostsTag__post_id", "PostsTag"."tag_id" AS "PostsTag__tag_id" FROM "tags" AS "Tag" JOIN "posts_tags" AS "PostsTag" ON ("PostsTag"."post_id" = '1' AND "PostsTag"."tag_id" = "Tag"."id") WHERE 1 = 1[[BR]] [[BR]] Error: ERROR: operator does not exist: character varying = integer LINE 1: ...PostsTag"."post_id" = '1' AND "PostsTag"."tag_id" = "Tag"."i... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.[[BR]] [[BR]] And the problematic query:[[BR]] [[BR]] Query #24: DELETE FROM "posts_tags" WHERE "post_id" IN ('1', '2')[[BR]] [[BR]] I'm unsure about the second save's results as the first eliminates extra rows that makes the second DELETE query unnecessary on ->save().[[BR]] [[BR]] I've attached the testcase. Also, I will apply my patch and post back with those results for MySQL and PostgreSQL. -- Ticket URL: <https://trac.cakephp.org/ticket/6245#comment:9> CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/> Cake is a rapid development framework for PHP which uses commonly known design patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "tickets cakephp" group. To post to this group, send email to tickets-cakephp@googlegroups.com To unsubscribe from this group, send email to tickets-cakephp+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/tickets-cakephp?hl=en -~----------~----~----~----~------~----~------~--~---