I was going to post this as a bug, but decided I should try here first.
Using Postgres, there is a problem with putting a query into
finderQuery. A similar query works correctly in the same context when
using MySQL It is a legal query, and the query attached to finderQuery
actually runs properly.
Version = 3148
In database.php:
var $default = array('driver' => 'postgres',
'connect' => 'pg_connect',
'host' => 'localhost',
'login' => 'dratman_dratman',
'password' => 'liquid',
'database' => 'dratman_schedule',
'prefix' => '');
Here is the model students.php.
<?php
class Student extends AppModel
{
var $name = 'Student';
var $hasAndBelongsToMany = array(
'Course' =>
array('className' => 'Course',
'conditions' => '',
'order' => '',
'foreignKey' => '',
'joinTable' => '',
'associationForeignKey' => '',
'uniq' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''),
);
var $hasMany = array(
'Scheduleblock' =>
array('className' => 'Scheduleblock',
'conditions' => '1 = 1',
'order' => '',
'finderQuery' =>
'SELECT
Scheduleblock.blockname,
subject,
teacher_fname,
teacher_lname
FROM
scheduleblocks as
Scheduleblock
LEFT JOIN
courses_students_scheduleblocks
ON
Scheduleblock.id =
scheduleblock_id
AND
student_id =
{$__cakeID__$}',
),
);
}
?>
Result:
There are no PHP errors indicated, only Postgres server errors, which
seem to me to be caused by a bug in Cake that appears only with
Postgres.
Multiple errors like the following appear in the browser:
Warning: pg_query(): Query failed: ERROR: syntax error at or near
"DEFAULT" at character 409 in
/home/dratman/railsapp/public/jengels/cake/libs/model/dbo/dbo_postgres.php
on line 108
In the query log, the query which was attached to finderQuery actually
SUCCEEDS and produces the desired result set. The problem is that
multiple "regular" queries after that one FAIL, having been mangled
like the following:
"Course__year", "Course"."semester" AS "Course__semester",
"Course"."social" AS "Course__social", "Course"."scheduleblock_id" AS
"Course__scheduleblock_id" FROM "courses" AS "Course" WHERE
"Course"."scheduleblock_id" = DEFAULT
There is always this word DEFAULT at the end, which is clearly
incorrect.
After 10 or so queries that fail, queries start succeeding again!
The word DEFAULT clearly does not belong at the end of the query shown
above, which was generated somewhere in Cake, not by my code. I don't
know which Cake source file to look at to try to fix this. I guess a
traceback is necessary, but I don't know how to produce one.
Note that any query attached to finderQuery produces the same bad
result -- it doesn't matter what the query is.
Thanks for any help someone might be able to offer!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---