permissionable icon indicating copy to clipboard operation
permissionable copied to clipboard

$this->Model->find('list'); fails on models with permissionable attached

Open darxmac opened this issue 13 years ago • 5 comments

When trying to do a $this->Model->find('list'); on a model that has the permissionable beavior attached it fails with the following SQL error: (this is for a model called Location

Warning (512): SQL Error: 1051: Unknown table 'LocationPermissionBit' [CORE/cake/libs/model/datasources/dbo_source.php, line 684]
Query: SELECT `Location`.`id`, `Location`.`name`, `LocationPermissionBit`.* FROM `locations` AS `Location`   WHERE 1 = 1    

darxmac avatar Jun 03 '11 20:06 darxmac

And you can fix it by adding 'recursive' => 0 to your $params array.

darxmac avatar Jun 03 '11 20:06 darxmac

strange. i'll see if i can track down what is causing it.

jmcneese avatar Jun 06 '11 04:06 jmcneese

I'm getting the same thing. I set the params variable to array('permissionable'=>false) to get it to work properly.

richardsession avatar Oct 28 '11 10:10 richardsession

I'm getting the same issue on mysql,

SELECT Store.*, StorePermissionBit.* FROM storesASStoreWHERE 1 = 1 ORDER BYnumber asc LIMIT 20

1051: Unknown table 'StorePermissionBit'

Any workaround that doesn't disable the permissionable behavior like above?

Thanks

ghost avatar Mar 09 '12 06:03 ghost

Hi guys, as a workaround you can put the following in your app model, credit to @darxmac for tracking down recursive=>0 being the problem:

       switch ($type) {
           case 'list':
                 $options['recursive'] = 0;
                 return parent::find('list', $options); 
           break;  
           default:  
               return parent::find($type, $options);
           break;
       }
   }

ghost avatar Mar 10 '12 04:03 ghost