While writing a unit test for a Model::delete in our application, I got 
some errors (see attached errors.txt). The point is that at some point Cake 
tries to execute the following query:

SELECT  FROM  AS `User` JOIN `users_institutes` AS `UsersInstitute` ON 
(`UsersInstitute`.`institute_id` = 521 AND `UsersInstitute`.`user_id` = 
`User`.``)

Which is obviously incorrect. The fields for the SELECT are empty and so is 
the name of the table and the value for the foreigen key in the User table.

I suspect this is because we have the following setup:

User HABTM Institute
Institute belongsTo Accountmanager (which is an alias of User)

See the attached models.php for the exact setup. All foreign keys etc. are 
correct and available in the database.

The strange thing is, the Model::delete works just fine, i.e. all data gets 
deleted and I don't see any errors in the web app. Only when I run my tests 
I get these errors. My test database is up-to-date and has the right 
fixtures though, so I'm a bit stuck here. I've poked around in the Cake 
core and found the error happens in the find method on line 1828 to 1831 of 
the delete method in model.php.

We're using Cake 1.3.6. Any thoughts on this?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php
E_WARNING: array_keys() expects parameter 1 to be array, null given in 
/usr/local/cakephp/cake/libs/model/datasources/dbo_source.php on line 1953
E_WARNING: array_keys() expects parameter 1 to be array, null given in 
/usr/local/cakephp/cake/libs/model/datasources/dbo_source.php on line 1966
E_WARNING: array_filter() expects parameter 1 to be array, null given in 
/usr/local/cakephp/cake/libs/model/datasources/dbo_source.php on line 1970
E_WARNING: array_values() expects parameter 1 to be array, null given in 
/usr/local/cakephp/cake/libs/model/datasources/dbo_source.php on line 1970
E_WARNING: array_unique() expects parameter 1 to be array, null given in 
/usr/local/cakephp/cake/libs/model/datasources/dbo_source.php on line 2052
E_WARNING: array_keys() expects parameter 1 to be array, null given in 
/usr/local/cakephp/cake/libs/model/datasources/dbo_source.php on line 1953
E_WARNING: array_keys() expects parameter 1 to be array, null given in 
/usr/local/cakephp/cake/libs/model/datasources/dbo_source.php on line 1966
E_WARNING: array_filter() expects parameter 1 to be array, null given in 
/usr/local/cakephp/cake/libs/model/datasources/dbo_source.php on line 1970
E_WARNING: array_values() expects parameter 1 to be array, null given in 
/usr/local/cakephp/cake/libs/model/datasources/dbo_source.php on line 1970
E_WARNING: array_unique() expects parameter 1 to be array, null given in 
/usr/local/cakephp/cake/libs/model/datasources/dbo_source.php on line 2052
E_WARNING: array_merge(): Argument #1 is not an array in 
/usr/local/cakephp/cake/libs/model/datasources/dbo_source.php on line 1357
E_WARNING: implode(): Invalid arguments passed in 
/usr/local/cakephp/cake/libs/model/datasources/dbo_source.php on line 1463
E_USER_WARNING: 
SQL Error: 1064: You have an error in your SQL syntax; check the manual that 
corresponds to your MySQL server version for the right syntax to use near 'FROM 
 AS `User` JOIN `users_institutes` AS `UsersInstitute` ON (`UsersInstitute`' at 
line 1</span> in /usr/local/cakephp/cake/libs/model/datasources/dbo_source.php 
on line 684
Query: SELECT  FROM  AS `User` JOIN `users_institutes` AS `UsersInstitute` ON 
(`UsersInstitute`.`institute_id` = 521 AND `UsersInstitute`.`user_id` = 
`User`.``)

<<attachment: models.php>>

Reply via email to